-
Notifications
You must be signed in to change notification settings - Fork 0
tuple
Name | Type |
---|---|
A |
readonly Runtype[] |
-
Runtype<{ [key in keyof A]: A[key] extends Runtype ? Static<A[key]> : unknown}>
↳ Tuple
• constructor: object
Inherited from: void
• Readonly
_falseWitness: { [key in string | number | symbol]: A[key] extends Runtype<unknown> ? Static<any[any]> : unknown}
Inherited from: Runtype._falseWitness
Defined in: src/runtype.ts:39
• components: A
Defined in: src/types/tuple.ts:13
• 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: tuple
Defined in: src/types/tuple.ts:12
▸ And<B>(B
: B): Intersect<[Tuple<A>, B]>
Intersect this Runtype with another.
Name | Type |
---|---|
B |
Runtype<unknown, B> |
Name | Type |
---|---|
B |
B |
Returns: Intersect<[Tuple<A>, B]>
Inherited from: Runtype
Defined in: src/runtype.ts:54
▸ Or<B>(B
: B): Union<[Tuple<A>, B]>
Union this Runtype with another.
Name | Type |
---|---|
B |
Runtype<unknown, B> |
Name | Type |
---|---|
B |
B |
Inherited from: Runtype
Defined in: src/runtype.ts:49
▸ assert(x
: any): asserts x is { [key in string | number | symbol]: A[key] extends Runtype<unknown> ? Static<any[any]> : unknown}
Verifies that a value conforms to this runtype. When given a value that does not conform to the runtype, throws an exception.
Name | Type |
---|---|
x |
any |
Returns: asserts x is { [key in string | number | symbol]: A[key] extends Runtype<unknown> ? Static<any[any]> : unknown}
Inherited from: Runtype
Defined in: src/runtype.ts:15
▸ check(x
: any): { [key in string | number | symbol]: A[key] extends Runtype<unknown> ? Static<any[any]> : unknown}
Verifies that a value conforms to this runtype. If so, returns the same value, statically typed. Otherwise throws an exception.
Name | Type |
---|---|
x |
any |
Returns: { [key in string | number | symbol]: A[key] extends Runtype<unknown> ? Static<any[any]> : unknown}
Inherited from: Runtype
Defined in: src/runtype.ts:21
▸ guard(x
: any): x is { [key in string | number | symbol]: A[key] extends Runtype<unknown> ? Static<any[any]> : unknown}
A type guard for this runtype.
Name | Type |
---|---|
x |
any |
Returns: x is { [key in string | number | symbol]: A[key] extends Runtype<unknown> ? Static<any[any]> : unknown}
Inherited from: Runtype
Defined in: src/runtype.ts:32
▸ optional(): Optional<Tuple<A>>
Optionalize this Runtype.
Inherited from: Runtype
Defined in: src/runtype.ts:59
▸ validate(x
: any): Result<{ [key in string | number | symbol]: A[key] extends Runtype<unknown> ? Static<any[any]> : unknown}>
Validates that a value conforms to this type, and returns a result indicating success or failure (does not throw).
Name | Type |
---|---|
x |
any |
Returns: Result<{ [key in string | number | symbol]: A[key] extends Runtype<unknown> ? Static<any[any]> : unknown}>
Inherited from: Runtype
Defined in: src/runtype.ts:27
▸ withBrand<B>(brand
: B): Brand<B, Tuple<A>>
Adds a brand to the type.
Name | Type |
---|---|
B |
string |
Name | Type |
---|---|
brand |
B |
Inherited from: Runtype
Defined in: src/runtype.ts:102
▸ withConstraint<T, K>(constraint
: ConstraintCheck<Tuple<A>>, options?
: { args?
: K ; name?
: string }): Constraint<Tuple<A>, T, K>
Use an arbitrary constraint function to validate a runtype, and optionally to change its name and/or its static type.
Name | Type | Default | Description |
---|---|---|---|
T |
{ [key in string | number | symbol]: A[key] extends Runtype<unknown> ? Static<any[any]> : unknown} | - | Optionally override the static type of the resulting runtype |
K |
- | unknown | - |
Name | Type | Description |
---|---|---|
constraint |
ConstraintCheck<Tuple<A>> | 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<Tuple<A>, T, K>
Inherited from: Runtype
Defined in: src/runtype.ts:74
▸ withGuard<T, K>(guard
: (x
: { [key in string | number | symbol]: A[key] extends Runtype<unknown> ? Static<any[any]> : unknown}) => x is T, options?
: { args?
: K ; name?
: string }): Constraint<Tuple<A>, 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.
Name | Type | Default | Description |
---|---|---|---|
T |
{ [key in string | number | symbol]: A[key] extends Runtype<unknown> ? Static<any[any]> : unknown} | - | Typically inferred from the return type of the type guard function, so usually not needed to specify manually. |
K |
- | unknown | - |
Name | Type | Description |
---|---|---|
guard |
(x : { [key in string | number | symbol]: A[key] extends Runtype<unknown> ? Static<any[any]> : unknown}) => 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<Tuple<A>, T, K>
Inherited from: Runtype
Defined in: src/runtype.ts:94