index overview
Added in v1.0.0
Table of contents
- Codec
- Decode error
- combinators
- constructors
- primitives
- utils
- Any (interface)
- AnyArrayType (class)
- AnyC (interface)
- AnyDictionaryType (class)
- AnyProps (interface)
- AnyType (class)
- ArrayC (interface)
- ArrayType (class)
- BigIntC (interface)
- BigIntType (class)
- BooleanC (interface)
- BooleanType (class)
- Brand (interface)
- BrandC (interface)
- Branded (type alias)
- Decode (type alias)
- DictionaryType (class)
- Encode (type alias)
- ExactC (interface)
- ExactType (class)
- FunctionC (interface)
- FunctionType (class)
- HasProps (type alias)
- HasPropsIntersection (interface)
- HasPropsReadonly (interface)
- HasPropsRefinement (interface)
- Int (type alias)
- IntBrand (interface)
- InterfaceType (class)
- IntersectionC (interface)
- IntersectionType (class)
- Is (type alias)
- KeyofC (interface)
- KeyofType (class)
- LiteralC (interface)
- LiteralType (class)
- Mixed (interface)
- NeverC (interface)
- NeverType (class)
- NullC (interface)
- NullType (class)
- NumberC (interface)
- NumberType (class)
- OutputOfDictionary (type alias)
- OutputOfPartialProps (type alias)
- OutputOfProps (type alias)
- PartialC (interface)
- PartialType (class)
- Props (interface)
- ReadonlyArrayC (interface)
- ReadonlyArrayType (class)
- ReadonlyC (interface)
- ReadonlyType (class)
- RecordC (interface)
- RecursiveType (class)
- RefinementC (interface)
- RefinementType (class)
- StringC (interface)
- StringType (class)
- TupleC (interface)
- TupleType (class)
- TypeC (interface)
- TypeOfDictionary (type alias)
- TypeOfPartialProps (type alias)
- TypeOfProps (type alias)
- UndefinedC (interface)
- UndefinedType (class)
- UnionC (interface)
- UnionType (class)
- UnknownArrayC (interface)
- UnknownC (interface)
- UnknownRecordC (interface)
- UnknownType (class)
- Validate (type alias)
- VoidC (interface)
- VoidType (class)
- appendContext
- getContextEntry
- getFunctionName
- identity
Compact(type alias)Exact(type alias)ObjectC(interface)ObjectType(class)PropsOf(type alias)StrictC(interface)StrictType(class)TaggedExact(interface)TaggedIntersectionArgument(type alias)TaggedIntersection(interface)TaggedProps(type alias)TaggedRefinement(interface)TaggedUnionC(interface)TaggedUnionType(class)TaggedUnion(interface)Tagged(type alias)getDefaultContextgetValidationErrormixed(type alias)
Codec
Decoder (interface)
Signature
export interface Decoder<I, A> {
readonly name: string
readonly validate: Validate<I, A>
readonly decode: Decode<I, A>
}
Added in v1.0.0
Encoder (interface)
Signature
export interface Encoder<A, O> {
readonly encode: Encode<A, O>
}
Added in v1.0.0
InputOf (type alias)
Signature
export type InputOf<C extends Any> = C['_I']
Added in v1.0.0
OutputOf (type alias)
Signature
export type OutputOf<C extends Any> = C['_O']
Added in v1.0.0
Type (class)
Signature
export declare class Type<A, O, I> {
constructor(
/** a unique name for this codec */
readonly name: string,
/** a custom type guard */
readonly is: Is<A>,
/** succeeds if a value of type I can be decoded to a value of type A */
readonly validate: Validate<I, A>,
/** converts a value of type A to a value of type O */
readonly encode: Encode<A, O>
)
}
Added in v1.0.0
pipe (method)
Signature
pipe<B, IB, A extends IB, OB extends A>(
this: Type<A, O, I>,
ab: Type<B, OB, IB>,
name = `pipe(${this.name}, ${ab.name})`
): Type<B, O, I>
Added in v1.0.0
asDecoder (method)
Signature
asDecoder(): Decoder<I, A>
Added in v1.0.0
asEncoder (method)
Signature
asEncoder(): Encoder<A, O>
Added in v1.0.0
decode (method)
a version of validate
with a default context
Signature
decode(i: I): Validation<A>
Added in v1.0.0
_A (property)
Signature
readonly _A: A
Added in v1.0.0
_O (property)
Signature
readonly _O: O
Added in v1.0.0
_I (property)
Signature
readonly _I: I
Added in v1.0.0
TypeOf (type alias)
Signature
export type TypeOf<C extends Any> = C['_A']
Added in v1.0.0
Decode error
Context (interface)
Signature
export interface Context extends ReadonlyArray<ContextEntry> {}
Added in v1.0.0
ContextEntry (interface)
Signature
export interface ContextEntry {
readonly key: string
readonly type: Decoder<any, any>
/** the input data */
readonly actual?: unknown
}
Added in v1.0.0
Errors (interface)
Signature
export interface Errors extends Array<ValidationError> {}
Added in v1.0.0
Validation (type alias)
Signature
export type Validation<A> = Either<Errors, A>
Added in v1.0.0
ValidationError (interface)
Signature
export interface ValidationError {
/** the offending (sub)value */
readonly value: unknown
/** where the error originated */
readonly context: Context
/** optional custom error message */
readonly message?: string
}
Added in v1.0.0
failure
Signature
export declare const failure: <T>(value: unknown, context: Context, message?: string | undefined) => Either<Errors, T>
Added in v1.0.0
failures
Signature
export declare const failures: <T>(errors: Errors) => Either<Errors, T>
Added in v1.0.0
success
Signature
export declare const success: <T>(value: T) => Either<Errors, T>
Added in v1.0.0
combinators
array
Signature
export declare function array<C extends Mixed>(item: C, name = `Array<${item.name}>`): ArrayC<C>
Added in v1.0.0
brand
Signature
export declare function brand<C extends Any, N extends string, B extends { readonly [K in N]: symbol }>(
codec: C,
predicate: Refinement<TypeOf<C>, Branded<TypeOf<C>, B>>,
name: N
): BrandC<C, B>
Added in v1.8.1
exact
Strips additional properties.
Signature
export declare function exact<C extends HasProps>(codec: C, name: string = getExactTypeName(codec)): ExactC<C>
Added in v1.1.0
intersection
Signature
export declare function intersection<
A extends Mixed,
B extends Mixed,
C extends Mixed,
D extends Mixed,
E extends Mixed
>(codecs: [A, B, C, D, E], name?: string): IntersectionC<[A, B, C, D, E]>
export declare function intersection<A extends Mixed, B extends Mixed, C extends Mixed, D extends Mixed>(
codecs: [A, B, C, D],
name?: string
): IntersectionC<[A, B, C, D]>
export declare function intersection<A extends Mixed, B extends Mixed, C extends Mixed>(
codecs: [A, B, C],
name?: string
): IntersectionC<[A, B, C]>
export declare function intersection<A extends Mixed, B extends Mixed>(
codecs: [A, B],
name?: string
): IntersectionC<[A, B]>
Added in v1.0.0
partial
Signature
export declare function partial<P extends Props>(
props: P,
name: string = getPartialTypeName(getInterfaceTypeName(props))
): PartialC<P>
Added in v1.0.0
readonly
Signature
export declare function readonly<C extends Mixed>(codec: C, name = `Readonly<${codec.name}>`): ReadonlyC<C>
Added in v1.0.0
readonlyArray
Signature
export declare function readonlyArray<C extends Mixed>(item: C, name = `ReadonlyArray<${item.name}>`): ReadonlyArrayC<C>
Added in v1.0.0
record
Signature
export declare function record<D extends Mixed, C extends Mixed>(domain: D, codomain: C, name?: string): RecordC<D, C>
Added in v1.7.1
recursion
Signature
export declare function recursion<A, O = A, I = unknown, C extends Type<A, O, I> = Type<A, O, I>>(
name: string,
definition: (self: C) => C
): RecursiveType<C, A, O, I>
Added in v1.0.0
refinement
Signature
export declare function refinement<C extends Any, B extends TypeOf<C>>(
codec: C,
refinement: Refinement<TypeOf<C>, B>,
name?: string
): RefinementC<C, B>
export declare function refinement<C extends Any>(
codec: C,
predicate: Predicate<TypeOf<C>>,
name?: string
): RefinementC<C>
Added in v1.0.0
strict
Strips additional properties, equivalent to exact(type(props))
.
Signature
export declare const strict: <P extends Props>(props: P, name?: string | undefined) => ExactC<TypeC<P>>
Added in v1.0.0
tuple
Signature
export declare function tuple<A extends Mixed, B extends Mixed, C extends Mixed, D extends Mixed, E extends Mixed>(
codecs: [A, B, C, D, E],
name?: string
): TupleC<[A, B, C, D, E]>
export declare function tuple<A extends Mixed, B extends Mixed, C extends Mixed, D extends Mixed>(
codecs: [A, B, C, D],
name?: string
): TupleC<[A, B, C, D]>
export declare function tuple<A extends Mixed, B extends Mixed, C extends Mixed>(
codecs: [A, B, C],
name?: string
): TupleC<[A, B, C]>
export declare function tuple<A extends Mixed, B extends Mixed>(codecs: [A, B], name?: string): TupleC<[A, B]>
export declare function tuple<A extends Mixed>(codecs: [A], name?: string): TupleC<[A]>
Added in v1.0.0
type
Signature
export declare function type<P extends Props>(props: P, name: string = getInterfaceTypeName(props)): TypeC<P>
Added in v1.0.0
union
Signature
export declare function union<CS extends [Mixed, Mixed, ...Array<Mixed>]>(
codecs: CS,
name: string = getUnionName(codecs)
): UnionC<CS>
Added in v1.0.0
alias
Keeps the codec “kind”.
Signature
export declare function alias<A, O, P, I>(
codec: PartialType<P, A, O, I>
): <AA extends A, OO extends O = O, PP extends P = P, II extends I = I>() => PartialType<PP, AA, OO, II>
export declare function alias<A, O, P, I>(
// tslint:disable-next-line: deprecation
codec: StrictType<P, A, O, I>
): <AA extends A, OO extends O = O, PP extends P = P, II extends I = I>() => // tslint:disable-next-line: deprecation
StrictType<PP, AA, OO, II>
export declare function alias<A, O, P, I>(
codec: InterfaceType<P, A, O, I>
): <AA extends A, OO extends O = O, PP extends P = P, II extends I = I>() => InterfaceType<PP, AA, OO, II>
Added in v1.1.0
clean
Drops the codec “kind”.
Signature
export declare function clean<A, O = A, I = unknown>(codec: Type<A, O, I>): Type<A, O, I>
Added in v1.1.0
dictionary
Use record
instead.
Signature
export declare const dictionary: typeof record
Added in v1.0.0
interface
Use type
instead.
Signature
export declare const interface: typeof type
Added in v1.0.0
taggedUnion
Use union
instead.
Signature
export declare const taggedUnion: <Tag extends string, CS extends [Mixed, Mixed, ...Mixed[]]>(
tag: Tag,
codecs: CS,
name?: string
) => TaggedUnionC<Tag, CS>
Added in v1.3.0
constructors
keyof
Signature
export declare function keyof<D extends { [key: string]: unknown }>(
keys: D,
name: string = Object.keys(keys)
.map((k) => JSON.stringify(k))
.join(' | ')
): KeyofC<D>
Added in v1.0.0
literal
Signature
export declare function literal<V extends LiteralValue>(value: V, name: string = JSON.stringify(value)): LiteralC<V>
Added in v1.0.0
primitives
Function
Signature
export declare const Function: FunctionC
Added in v1.0.0
Int
A branded codec representing an integer
Signature
export declare const Int: BrandC<NumberC, IntBrand>
Added in v1.8.1
Integer
Signature
export declare const Integer: RefinementC<NumberC, number>
Added in v1.0.0
UnknownArray
Signature
export declare const UnknownArray: UnknownArrayC
Added in v1.7.1
UnknownRecord
Signature
export declare const UnknownRecord: UnknownRecordC
Added in v1.7.1
any
Signature
export declare const any: AnyC
Added in v1.0.0
bigint
Signature
export declare const bigint: BigIntC
Added in v2.1.0
boolean
Signature
export declare const boolean: BooleanC
Added in v1.0.0
never
Signature
export declare const never: NeverC
Added in v1.0.0
null
Signature
export declare const null: NullC
Added in v1.0.0
nullType
Signature
export declare const nullType: NullC
Added in v1.0.0
number
Signature
export declare const number: NumberC
Added in v1.0.0
string
Signature
export declare const string: StringC
Added in v1.0.0
undefined
Signature
export declare const undefined: UndefinedC
Added in v1.0.0
unknown
Signature
export declare const unknown: UnknownC
Added in v1.5.0
void
Signature
export declare const void: VoidC
Added in v1.0.0
voidType
Signature
export declare const voidType: VoidC
Added in v1.2.0
Array
Use UnknownArray
instead.
Signature
export declare const Array: UnknownArrayC
Added in v1.0.0
Dictionary
Use UnknownRecord
instead.
Signature
export declare const Dictionary: UnknownRecordC
Added in v1.0.0
object
Use UnknownRecord
instead.
Signature
export declare const object: ObjectC
Added in v1.0.0
utils
Any (interface)
Signature
export interface Any extends Type<any, any, any> {}
Added in v1.0.0
AnyArrayType (class)
Signature
export declare class AnyArrayType {
constructor()
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "AnyArrayType"
Added in v1.0.0
AnyC (interface)
Signature
export interface AnyC extends AnyType {}
Added in v1.5.3
AnyDictionaryType (class)
Signature
export declare class AnyDictionaryType {
constructor()
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "AnyDictionaryType"
Added in v1.0.0
AnyProps (interface)
Signature
export interface AnyProps {
[key: string]: Any
}
Added in v1.0.0
AnyType (class)
Signature
export declare class AnyType {
constructor()
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "AnyType"
Added in v1.0.0
ArrayC (interface)
Signature
export interface ArrayC<C extends Mixed> extends ArrayType<C, Array<TypeOf<C>>, Array<OutputOf<C>>, unknown> {}
Added in v1.5.3
ArrayType (class)
Signature
export declare class ArrayType<C, A, O, I> {
constructor(
name: string,
is: ArrayType<C, A, O, I>['is'],
validate: ArrayType<C, A, O, I>['validate'],
encode: ArrayType<C, A, O, I>['encode'],
readonly type: C
)
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "ArrayType"
Added in v1.0.0
BigIntC (interface)
Signature
export interface BigIntC extends BigIntType {}
Added in v2.1.0
BigIntType (class)
Signature
export declare class BigIntType {
constructor()
}
Added in v2.1.0
_tag (property)
Signature
readonly _tag: "BigIntType"
Added in v1.0.0
BooleanC (interface)
Signature
export interface BooleanC extends BooleanType {}
Added in v1.5.3
BooleanType (class)
Signature
export declare class BooleanType {
constructor()
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "BooleanType"
Added in v1.0.0
Brand (interface)
Signature
export interface Brand<B> {
readonly [_brand]: B
}
Added in v1.8.1
BrandC (interface)
Signature
export interface BrandC<C extends Any, B> extends RefinementType<C, Branded<TypeOf<C>, B>, OutputOf<C>, InputOf<C>> {}
Added in v1.8.1
Branded (type alias)
Signature
export type Branded<A, B> = A & Brand<B>
Added in v1.8.1
Decode (type alias)
Signature
export type Decode<I, A> = (i: I) => Validation<A>
Added in v1.0.0
DictionaryType (class)
Signature
export declare class DictionaryType<D, C, A, O, I> {
constructor(
name: string,
is: DictionaryType<D, C, A, O, I>['is'],
validate: DictionaryType<D, C, A, O, I>['validate'],
encode: DictionaryType<D, C, A, O, I>['encode'],
readonly domain: D,
readonly codomain: C
)
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "DictionaryType"
Added in v1.0.0
Encode (type alias)
Signature
export type Encode<A, O> = (a: A) => O
Added in v1.0.0
ExactC (interface)
Signature
export interface ExactC<C extends HasProps> extends ExactType<C, TypeOf<C>, OutputOf<C>, InputOf<C>> {}
Added in v1.5.3
ExactType (class)
Signature
export declare class ExactType<C, A, O, I> {
constructor(
name: string,
is: ExactType<C, A, O, I>['is'],
validate: ExactType<C, A, O, I>['validate'],
encode: ExactType<C, A, O, I>['encode'],
readonly type: C
)
}
Added in v1.1.0
_tag (property)
Signature
readonly _tag: "ExactType"
Added in v1.0.0
FunctionC (interface)
Signature
export interface FunctionC extends FunctionType {}
Added in v1.5.3
FunctionType (class)
Signature
export declare class FunctionType {
constructor()
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "FunctionType"
Added in v1.0.0
HasProps (type alias)
Signature
export type HasProps =
| HasPropsRefinement
| HasPropsReadonly
| HasPropsIntersection
| InterfaceType<any, any, any, any>
// tslint:disable-next-line: deprecation
| StrictType<any, any, any, any>
| PartialType<any, any, any, any>
Added in v1.1.0
HasPropsIntersection (interface)
Signature
export interface HasPropsIntersection extends IntersectionType<Array<HasProps>, any, any, any> {}
Added in v1.1.0
HasPropsReadonly (interface)
Signature
export interface HasPropsReadonly extends ReadonlyType<HasProps, any, any, any> {}
Added in v1.1.0
HasPropsRefinement (interface)
Signature
export interface HasPropsRefinement extends RefinementType<HasProps, any, any, any> {}
Added in v1.1.0
Int (type alias)
Signature
export type Int = Branded<number, IntBrand>
Added in v1.8.1
IntBrand (interface)
Signature
export interface IntBrand {
readonly Int: unique symbol
}
Added in v1.8.1
InterfaceType (class)
Signature
export declare class InterfaceType<P, A, O, I> {
constructor(
name: string,
is: InterfaceType<P, A, O, I>['is'],
validate: InterfaceType<P, A, O, I>['validate'],
encode: InterfaceType<P, A, O, I>['encode'],
readonly props: P
)
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "InterfaceType"
Added in v1.0.0
IntersectionC (interface)
Signature
export interface IntersectionC<CS extends [Mixed, Mixed, ...Array<Mixed>]>
extends IntersectionType<
CS,
CS extends { length: 2 }
? TypeOf<CS[0]> & TypeOf<CS[1]>
: CS extends { length: 3 }
? TypeOf<CS[0]> & TypeOf<CS[1]> & TypeOf<CS[2]>
: CS extends { length: 4 }
? TypeOf<CS[0]> & TypeOf<CS[1]> & TypeOf<CS[2]> & TypeOf<CS[3]>
: CS extends { length: 5 }
? TypeOf<CS[0]> & TypeOf<CS[1]> & TypeOf<CS[2]> & TypeOf<CS[3]> & TypeOf<CS[4]>
: unknown,
CS extends { length: 2 }
? OutputOf<CS[0]> & OutputOf<CS[1]>
: CS extends { length: 3 }
? OutputOf<CS[0]> & OutputOf<CS[1]> & OutputOf<CS[2]>
: CS extends { length: 4 }
? OutputOf<CS[0]> & OutputOf<CS[1]> & OutputOf<CS[2]> & OutputOf<CS[3]>
: CS extends { length: 5 }
? OutputOf<CS[0]> & OutputOf<CS[1]> & OutputOf<CS[2]> & OutputOf<CS[3]> & OutputOf<CS[4]>
: unknown,
unknown
> {}
Added in v1.5.3
IntersectionType (class)
Signature
export declare class IntersectionType<CS, A, O, I> {
constructor(
name: string,
is: IntersectionType<CS, A, O, I>['is'],
validate: IntersectionType<CS, A, O, I>['validate'],
encode: IntersectionType<CS, A, O, I>['encode'],
readonly types: CS
)
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "IntersectionType"
Added in v1.0.0
Is (type alias)
Signature
export type Is<A> = (u: unknown) => u is A
Added in v1.0.0
KeyofC (interface)
Signature
export interface KeyofC<D extends { [key: string]: unknown }> extends KeyofType<D> {}
Added in v1.5.3
KeyofType (class)
Signature
export declare class KeyofType<D> {
constructor(
name: string,
is: KeyofType<D>['is'],
validate: KeyofType<D>['validate'],
encode: KeyofType<D>['encode'],
readonly keys: D
)
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "KeyofType"
Added in v1.0.0
LiteralC (interface)
Signature
export interface LiteralC<V extends LiteralValue> extends LiteralType<V> {}
Added in v1.5.3
LiteralType (class)
Signature
export declare class LiteralType<V> {
constructor(
name: string,
is: LiteralType<V>['is'],
validate: LiteralType<V>['validate'],
encode: LiteralType<V>['encode'],
readonly value: V
)
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "LiteralType"
Added in v1.0.0
Mixed (interface)
Signature
export interface Mixed extends Type<any, any, unknown> {}
Added in v1.0.0
NeverC (interface)
Signature
export interface NeverC extends NeverType {}
Added in v1.5.3
NeverType (class)
Signature
export declare class NeverType {
constructor()
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "NeverType"
Added in v1.0.0
NullC (interface)
Signature
export interface NullC extends NullType {}
Added in v1.5.3
NullType (class)
Signature
export declare class NullType {
constructor()
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "NullType"
Added in v1.0.0
NumberC (interface)
Signature
export interface NumberC extends NumberType {}
Added in v1.5.3
NumberType (class)
Signature
export declare class NumberType {
constructor()
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "NumberType"
Added in v1.0.0
OutputOfDictionary (type alias)
Signature
export type OutputOfDictionary<D extends Any, C extends Any> = { [K in OutputOf<D>]: OutputOf<C> }
Added in v1.0.0
OutputOfPartialProps (type alias)
Signature
export type OutputOfPartialProps<P extends AnyProps> = { [K in keyof P]?: OutputOf<P[K]> }
Added in v1.0.0
OutputOfProps (type alias)
Signature
export type OutputOfProps<P extends AnyProps> = { [K in keyof P]: OutputOf<P[K]> }
Added in v1.0.0
PartialC (interface)
Signature
export interface PartialC<P extends Props>
extends PartialType<P, { [K in keyof P]?: TypeOf<P[K]> }, { [K in keyof P]?: OutputOf<P[K]> }, unknown> {}
Added in v1.5.3
PartialType (class)
Signature
export declare class PartialType<P, A, O, I> {
constructor(
name: string,
is: PartialType<P, A, O, I>['is'],
validate: PartialType<P, A, O, I>['validate'],
encode: PartialType<P, A, O, I>['encode'],
readonly props: P
)
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "PartialType"
Added in v1.0.0
Props (interface)
Signature
export interface Props {
[key: string]: Mixed
}
Added in v1.0.0
ReadonlyArrayC (interface)
Signature
export interface ReadonlyArrayC<C extends Mixed>
extends ReadonlyArrayType<C, ReadonlyArray<TypeOf<C>>, ReadonlyArray<OutputOf<C>>, unknown> {}
Added in v1.5.3
ReadonlyArrayType (class)
Signature
export declare class ReadonlyArrayType<C, A, O, I> {
constructor(
name: string,
is: ReadonlyArrayType<C, A, O, I>['is'],
validate: ReadonlyArrayType<C, A, O, I>['validate'],
encode: ReadonlyArrayType<C, A, O, I>['encode'],
readonly type: C
)
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "ReadonlyArrayType"
Added in v1.0.0
ReadonlyC (interface)
Signature
export interface ReadonlyC<C extends Mixed>
extends ReadonlyType<C, Readonly<TypeOf<C>>, Readonly<OutputOf<C>>, unknown> {}
Added in v1.5.3
ReadonlyType (class)
Signature
export declare class ReadonlyType<C, A, O, I> {
constructor(
name: string,
is: ReadonlyType<C, A, O, I>['is'],
validate: ReadonlyType<C, A, O, I>['validate'],
encode: ReadonlyType<C, A, O, I>['encode'],
readonly type: C
)
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "ReadonlyType"
Added in v1.0.0
RecordC (interface)
Signature
export interface RecordC<D extends Mixed, C extends Mixed>
extends DictionaryType<D, C, { [K in TypeOf<D>]: TypeOf<C> }, { [K in OutputOf<D>]: OutputOf<C> }, unknown> {}
Added in v1.5.3
RecursiveType (class)
Signature
export declare class RecursiveType<C, A, O, I> {
constructor(
name: string,
is: RecursiveType<C, A, O, I>['is'],
validate: RecursiveType<C, A, O, I>['validate'],
encode: RecursiveType<C, A, O, I>['encode'],
public runDefinition: () => C
)
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "RecursiveType"
Added in v1.0.0
type (property)
Signature
readonly type: C
Added in v1.0.0
RefinementC (interface)
Signature
export interface RefinementC<C extends Any, B = TypeOf<C>> extends RefinementType<C, B, OutputOf<C>, InputOf<C>> {}
Added in v1.5.3
RefinementType (class)
Signature
export declare class RefinementType<C, A, O, I> {
constructor(
name: string,
is: RefinementType<C, A, O, I>['is'],
validate: RefinementType<C, A, O, I>['validate'],
encode: RefinementType<C, A, O, I>['encode'],
readonly type: C,
readonly predicate: Predicate<A>
)
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "RefinementType"
Added in v1.0.0
StringC (interface)
Signature
export interface StringC extends StringType {}
Added in v1.5.3
StringType (class)
Signature
export declare class StringType {
constructor()
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "StringType"
Added in v1.0.0
TupleC (interface)
Signature
export interface TupleC<CS extends [Mixed, ...Array<Mixed>]>
extends TupleType<
CS,
CS extends { length: 1 }
? [TypeOf<CS[0]>]
: CS extends { length: 2 }
? [TypeOf<CS[0]>, TypeOf<CS[1]>]
: CS extends { length: 3 }
? [TypeOf<CS[0]>, TypeOf<CS[1]>, TypeOf<CS[2]>]
: CS extends { length: 4 }
? [TypeOf<CS[0]>, TypeOf<CS[1]>, TypeOf<CS[2]>, TypeOf<CS[3]>]
: CS extends { length: 5 }
? [TypeOf<CS[0]>, TypeOf<CS[1]>, TypeOf<CS[2]>, TypeOf<CS[3]>, TypeOf<CS[4]>]
: unknown,
CS extends { length: 1 }
? [OutputOf<CS[0]>]
: CS extends { length: 2 }
? [OutputOf<CS[0]>, OutputOf<CS[1]>]
: CS extends { length: 3 }
? [OutputOf<CS[0]>, OutputOf<CS[1]>, OutputOf<CS[2]>]
: CS extends { length: 4 }
? [OutputOf<CS[0]>, OutputOf<CS[1]>, OutputOf<CS[2]>, OutputOf<CS[3]>]
: CS extends { length: 5 }
? [OutputOf<CS[0]>, OutputOf<CS[1]>, OutputOf<CS[2]>, OutputOf<CS[3]>, OutputOf<CS[4]>]
: unknown,
unknown
> {}
Added in v1.5.3
TupleType (class)
Signature
export declare class TupleType<CS, A, O, I> {
constructor(
name: string,
is: TupleType<CS, A, O, I>['is'],
validate: TupleType<CS, A, O, I>['validate'],
encode: TupleType<CS, A, O, I>['encode'],
readonly types: CS
)
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "TupleType"
Added in v1.0.0
TypeC (interface)
Signature
export interface TypeC<P extends Props>
extends InterfaceType<P, { [K in keyof P]: TypeOf<P[K]> }, { [K in keyof P]: OutputOf<P[K]> }, unknown> {}
Added in v1.5.3
TypeOfDictionary (type alias)
Signature
export type TypeOfDictionary<D extends Any, C extends Any> = { [K in TypeOf<D>]: TypeOf<C> }
Added in v1.0.0
TypeOfPartialProps (type alias)
Signature
export type TypeOfPartialProps<P extends AnyProps> = { [K in keyof P]?: TypeOf<P[K]> }
Added in v1.0.0
TypeOfProps (type alias)
Signature
export type TypeOfProps<P extends AnyProps> = { [K in keyof P]: TypeOf<P[K]> }
Added in v1.0.0
UndefinedC (interface)
Signature
export interface UndefinedC extends UndefinedType {}
Added in v1.5.3
UndefinedType (class)
Signature
export declare class UndefinedType {
constructor()
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "UndefinedType"
Added in v1.0.0
UnionC (interface)
Signature
export interface UnionC<CS extends [Mixed, Mixed, ...Array<Mixed>]>
extends UnionType<CS, TypeOf<CS[number]>, OutputOf<CS[number]>, unknown> {}
Added in v1.5.3
UnionType (class)
Signature
export declare class UnionType<CS, A, O, I> {
constructor(
name: string,
is: UnionType<CS, A, O, I>['is'],
validate: UnionType<CS, A, O, I>['validate'],
encode: UnionType<CS, A, O, I>['encode'],
readonly types: CS
)
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "UnionType"
Added in v1.0.0
UnknownArrayC (interface)
Signature
export interface UnknownArrayC extends AnyArrayType {}
Added in v1.5.3
UnknownC (interface)
Signature
export interface UnknownC extends UnknownType {}
Added in v1.5.3
UnknownRecordC (interface)
Signature
export interface UnknownRecordC extends AnyDictionaryType {}
Added in v1.5.3
UnknownType (class)
Signature
export declare class UnknownType {
constructor()
}
Added in v1.5.0
_tag (property)
Signature
readonly _tag: "UnknownType"
Added in v1.0.0
Validate (type alias)
Signature
export type Validate<I, A> = (i: I, context: Context) => Validation<A>
Added in v1.0.0
VoidC (interface)
Signature
export interface VoidC extends VoidType {}
Added in v1.5.3
VoidType (class)
Signature
export declare class VoidType {
constructor()
}
Added in v1.2.0
_tag (property)
Signature
readonly _tag: "VoidType"
Added in v1.0.0
appendContext
Signature
export declare function appendContext(c: Context, key: string, decoder: Decoder<any, any>, actual?: unknown): Context
Added in v1.0.0
getContextEntry
Signature
export declare function getContextEntry(key: string, decoder: Decoder<any, any>): ContextEntry
Added in v1.0.0
getFunctionName
Signature
export declare function getFunctionName(f: Function): string
Added in v1.0.0
identity
Signature
export declare const identity: <A>(a: A) => A
Added in v1.0.0
Compact (type alias)
Signature
export type Compact<A> = { [K in keyof A]: A[K] }
Added in v1.4.2
Exact (type alias)
Signature
export type Exact<T, X extends T> = T & {
[K in ({ [K in keyof X]: K } & { [K in keyof T]: never } & { [key: string]: never })[keyof X]]?: never
}
Added in v1.1.0
ObjectC (interface)
Signature
export interface ObjectC extends ObjectType {}
Added in v1.5.3
ObjectType (class)
Signature
export declare class ObjectType {
constructor()
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "ObjectType"
Added in v1.0.0
PropsOf (type alias)
Signature
export type PropsOf<T extends { props: any }> = T['props']
Added in v1.0.0
StrictC (interface)
Signature
export interface StrictC<P extends Props> // tslint:disable-next-line: deprecation
extends StrictType<P, { [K in keyof P]: TypeOf<P[K]> }, { [K in keyof P]: OutputOf<P[K]> }, unknown> {}
Added in v1.5.3
StrictType (class)
Signature
export declare class StrictType<P, A, O, I> {
constructor(
name: string,
// tslint:disable-next-line: deprecation
is: StrictType<P, A, O, I>['is'],
// tslint:disable-next-line: deprecation
validate: StrictType<P, A, O, I>['validate'],
// tslint:disable-next-line: deprecation
encode: StrictType<P, A, O, I>['encode'],
readonly props: P
)
}
Added in v1.0.0
_tag (property)
Signature
readonly _tag: "StrictType"
Added in v1.0.0
TaggedExact (interface)
Signature
export interface TaggedExact<Tag extends string, A, O = A> extends ExactType<Tagged<Tag>, A, O> {}
Added in v1.3.0
TaggedIntersectionArgument (type alias)
Signature
export type TaggedIntersectionArgument<Tag extends string> =
// tslint:disable-next-line: deprecation
| [Tagged<Tag>]
// tslint:disable-next-line: deprecation
| [Tagged<Tag>, Mixed]
// tslint:disable-next-line: deprecation
| [Mixed, Tagged<Tag>]
// tslint:disable-next-line: deprecation
| [Tagged<Tag>, Mixed, Mixed]
// tslint:disable-next-line: deprecation
| [Mixed, Tagged<Tag>, Mixed]
// tslint:disable-next-line: deprecation
| [Mixed, Mixed, Tagged<Tag>]
// tslint:disable-next-line: deprecation
| [Tagged<Tag>, Mixed, Mixed, Mixed]
// tslint:disable-next-line: deprecation
| [Mixed, Tagged<Tag>, Mixed, Mixed]
// tslint:disable-next-line: deprecation
| [Mixed, Mixed, Tagged<Tag>, Mixed]
// tslint:disable-next-line: deprecation
| [Mixed, Mixed, Mixed, Tagged<Tag>]
// tslint:disable-next-line: deprecation
| [Tagged<Tag>, Mixed, Mixed, Mixed, Mixed]
// tslint:disable-next-line: deprecation
| [Mixed, Tagged<Tag>, Mixed, Mixed, Mixed]
// tslint:disable-next-line: deprecation
| [Mixed, Mixed, Tagged<Tag>, Mixed, Mixed]
// tslint:disable-next-line: deprecation
| [Mixed, Mixed, Mixed, Tagged<Tag>, Mixed]
// tslint:disable-next-line: deprecation
| [Mixed, Mixed, Mixed, Mixed, Tagged<Tag>]
Added in v1.3.0
TaggedIntersection (interface)
Signature
export interface TaggedIntersection<Tag extends string, A, O = A> // tslint:disable-next-line: deprecation
extends IntersectionType<TaggedIntersectionArgument<Tag>, A, O> {}
Added in v1.3.0
TaggedProps (type alias)
Signature
export type TaggedProps<Tag extends string> = { [K in Tag]: LiteralType<any> }
Added in v1.3.0
TaggedRefinement (interface)
Signature
export interface TaggedRefinement<Tag extends string, A, O = A> extends RefinementType<Tagged<Tag>, A, O> {}
Added in v1.3.0
TaggedUnionC (interface)
Signature
export interface TaggedUnionC<Tag extends string, CS extends [Mixed, Mixed, ...Array<Mixed>]> // tslint:disable-next-line: deprecation
extends TaggedUnionType<Tag, CS, TypeOf<CS[number]>, OutputOf<CS[number]>, unknown> {}
Added in v1.5.3
TaggedUnionType (class)
Signature
export declare class TaggedUnionType<Tag, CS, A, O, I> {
constructor(
name: string,
// tslint:disable-next-line: deprecation
is: TaggedUnionType<Tag, CS, A, O, I>['is'],
// tslint:disable-next-line: deprecation
validate: TaggedUnionType<Tag, CS, A, O, I>['validate'],
// tslint:disable-next-line: deprecation
encode: TaggedUnionType<Tag, CS, A, O, I>['encode'],
codecs: CS,
readonly tag: Tag
)
}
Added in v1.3.0
TaggedUnion (interface)
Signature
export interface TaggedUnion<Tag extends string, A, O = A> extends UnionType<Array<Tagged<Tag>>, A, O> {}
Added in v1.3.0
Tagged (type alias)
Signature
export type Tagged<Tag extends string, A = any, O = A> =
// tslint:disable-next-line: deprecation
| InterfaceType<TaggedProps<Tag>, A, O>
// tslint:disable-next-line: deprecation
| StrictType<TaggedProps<Tag>, A, O>
// tslint:disable-next-line: deprecation
| TaggedRefinement<Tag, A, O>
// tslint:disable-next-line: deprecation
| TaggedUnion<Tag, A, O>
// tslint:disable-next-line: deprecation
| TaggedIntersection<Tag, A, O>
// tslint:disable-next-line: deprecation
| TaggedExact<Tag, A, O>
| RecursiveType<any, A, O>
Added in v1.3.0
getDefaultContext
Signature
export declare const getDefaultContext: (decoder: Decoder<any, any>) => Context
Added in v1.0.0
getValidationError
Signature
export declare const getValidationError: (value: unknown, context: Context) => ValidationError
Added in v1.0.0
mixed (type alias)
Use unknown
instead.
Signature
export type mixed = unknown
Added in v1.0.0