Skip to content
This repository was archived by the owner on Aug 23, 2024. It is now read-only.

stringdictionary

github-actions[bot] edited this page Apr 1, 2021 · 5 revisions

runtypes / Exports / StringDictionary

Interface: StringDictionary<V>

Type parameters

Name Type
V Runtype

Hierarchy

Table of contents

Properties

Methods

Properties

_falseWitness

Readonly _falseWitness: object

Type declaration:

Inherited from: Runtype._falseWitness

Defined in: src/runtype.ts:39


key

key: string

Defined in: src/types/dictionary.ts:29


reflect

Readonly reflect: Reflect

Convert this to a Reflect, capable of introspecting the structure of the type.

Inherited from: Runtype.reflect

Defined in: src/runtype.ts:37


tag

tag: dictionary

Defined in: src/types/dictionary.ts:28


value

value: V

Defined in: src/types/dictionary.ts:30

Methods

And

And<B>(B: B): Intersect<[StringDictionary<V>, B]>

Intersect this Runtype with another.

Type parameters:

Name Type
B Runtype<unknown, B>

Parameters:

Name Type
B B

Returns: Intersect<[StringDictionary<V>, B]>

Inherited from: Runtype

Defined in: src/runtype.ts:54


Or

Or<B>(B: B): Union<[StringDictionary<V>, B]>

Union this Runtype with another.

Type parameters:

Name Type
B Runtype<unknown, B>

Parameters:

Name Type
B B

Returns: Union<[StringDictionary<V>, B]>

Inherited from: Runtype

Defined in: src/runtype.ts:49


assert

assert(x: any): asserts x is object

Verifies that a value conforms to this runtype. When given a value that does not conform to the runtype, throws an exception.

Parameters:

Name Type
x any

Returns: asserts x is object

Inherited from: Runtype

Defined in: src/runtype.ts:15


check

check(x: any): object

Verifies that a value conforms to this runtype. If so, returns the same value, statically typed. Otherwise throws an exception.

Parameters:

Name Type
x any

Returns: object

Inherited from: Runtype

Defined in: src/runtype.ts:21


guard

guard(x: any): x is object

A type guard for this runtype.

Parameters:

Name Type
x any

Returns: x is object

Inherited from: Runtype

Defined in: src/runtype.ts:32


optional

optional(): Optional<StringDictionary<V>>

Optionalize this Runtype.

Returns: Optional<StringDictionary<V>>

Inherited from: Runtype

Defined in: src/runtype.ts:59


validate

validate(x: any): Result<{ [_: string]: Static<V>; }>

Validates that a value conforms to this type, and returns a result indicating success or failure (does not throw).

Parameters:

Name Type
x any

Returns: Result<{ [_: string]: Static<V>; }>

Inherited from: Runtype

Defined in: src/runtype.ts:27


withBrand

withBrand<B>(brand: B): Brand<B, StringDictionary<V>>

Adds a brand to the type.

Type parameters:

Name Type
B string

Parameters:

Name Type
brand B

Returns: Brand<B, StringDictionary<V>>

Inherited from: Runtype

Defined in: src/runtype.ts:102


withConstraint

withConstraint<T, K>(constraint: ConstraintCheck<StringDictionary<V>>, options?: { args?: K ; name?: string }): Constraint<StringDictionary<V>, T, K>

Use an arbitrary constraint function to validate a runtype, and optionally to change its name and/or its static type.

Type parameters:

Name Type Default Description
T object - Optionally override the static type of the resulting runtype
K - unknown -

Parameters:

Name Type Description
constraint ConstraintCheck<StringDictionary<V>> Custom function that returns true if the constraint is satisfied, false or a custom error message if not.
options? object -
options.args? K -
options.name? string -

Returns: Constraint<StringDictionary<V>, T, K>

Inherited from: Runtype

Defined in: src/runtype.ts:74


withGuard

withGuard<T, K>(guard: (x: { [_: string]: Static<V>; }) => x is T, options?: { args?: K ; name?: string }): Constraint<StringDictionary<V>, T, K>

Helper function to convert an underlying Runtype into another static type via a type guard function. The static type of the runtype is inferred from the type of the guard function.

Type parameters:

Name Type Default Description
T object - Typically inferred from the return type of the type guard function, so usually not needed to specify manually.
K - unknown -

Parameters:

Name Type Description
guard (x: { [_: string]: Static<V>; }) => x is T Type guard function (see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards)
options? object -
options.args? K -
options.name? string -

Returns: Constraint<StringDictionary<V>, T, K>

Inherited from: Runtype

Defined in: src/runtype.ts:94