import { Struct, StructType, StructContext } from './struct'; import { StructRecord, StructTuple } from './utils'; /** * Validate any value. */ export declare function any(): Struct; /** * Validate that an array of values of a specific type. */ export declare function array(): Struct; export declare function array(Element: Struct): Struct>; /** * Validate that boolean values. */ export declare function boolean(): Struct; /** * Validate that `Date` values. * * Note: this also ensures that the value is *not* an invalid `Date` object, * which can occur when parsing a date fails but still returns a `Date`. */ export declare function date(): Struct; /** * Validate that a value dynamically, determing which struct to use at runtime. */ export declare function dynamic(fn: (value: unknown, ctx: StructContext) => Struct): Struct; /** * Validate that a value against a set of potential values. */ export declare function enums(values: T[]): Struct; export declare function enums(values: T[]): Struct; /** * Validate that a value is a function. */ export declare function func(): Struct; /** * Validate that a value is an instance of a class. */ export declare function instance(Class: T): Struct>; /** * Validate that a value matches all of a set of structs. */ export declare function intersection(Structs: StructTuple<[A]>): Struct; export declare function intersection(Structs: StructTuple<[A, B]>): Struct; export declare function intersection(Structs: StructTuple<[A, B, C]>): Struct; export declare function intersection(Structs: StructTuple<[A, B, C, D]>): Struct; export declare function intersection(Structs: StructTuple<[A, B, C, D, E]>): Struct; export declare function intersection(Structs: StructTuple<[A, B, C, D, E, F]>): Struct; export declare function intersection(Structs: StructTuple<[A, B, C, D, E, F, G]>): Struct; export declare function intersection(Structs: StructTuple<[A, B, C, D, E, F, G, H]>): Struct; export declare function intersection(Structs: StructTuple<[A, B, C, D, E, F, G, H, I]>): Struct; export declare function intersection(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J]>): Struct; export declare function intersection(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K]>): Struct; export declare function intersection(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L]>): Struct; export declare function intersection(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L, M]>): Struct; export declare function intersection(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L, M, N]>): Struct; export declare function intersection(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O]>): Struct; export declare function intersection(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P]>): Struct; export declare function intersection(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q]>): Struct; /** * Validate a value lazily, by constructing the struct right before the first * validation. This is useful for cases where you want to have self-referential * structs for nested data structures. */ export declare function lazy(fn: () => Struct): Struct; /** * Validate that a value is a specific constant. */ export declare function literal(constant: T): Struct; export declare function literal(constant: T): Struct; export declare function literal(constant: T): Struct; export declare function literal(constant: T): Struct; /** * Validate that a value is a map with specific key and value entries. */ export declare function map(Key: Struct, Value: Struct): Struct>; /** * Validate that a value always fails. */ export declare function never(): Struct; /** * Augment a struct to make it accept `null` values. */ export declare function nullable(S: Struct): Struct; /** * Validate that a value is a number. */ export declare function number(): Struct; /** * Type helper to Flatten the Union of optional and required properties. */ declare type Flatten = T extends infer U ? { [K in keyof U]: U[K]; } : never; /** * Type helper to extract the optional keys of an object */ declare type OptionalKeys = { [K in keyof T]: undefined extends T[K] ? K : never; }[keyof T]; /** * Type helper to extract the required keys of an object */ declare type RequiredKeys = { [K in keyof T]: undefined extends T[K] ? never : K; }[keyof T]; /** * Type helper to create optional properties when the property value can be * undefined (ie. when `optional()` is used to define a type) */ declare type OptionalizeObject = Flatten<{ [K in RequiredKeys]: T[K]; } & { [K in OptionalKeys]?: T[K]; }>; /** * Validate that an object with specific entry values. */ export declare function object>(): Struct>; export declare function object>(Structs: V): Struct; }>, V>; /** * Augment a struct to make it optionally accept `undefined` values. */ export declare function optional(S: Struct): Struct; /** * Validate that a partial object with specific entry values. */ export declare function partial>(Structs: V | Struct): Struct<{ [K in keyof V]?: StructType; }>; /** * Validate that a value is a record with specific key and * value entries. */ export declare function record(Key: Struct, Value: Struct): Struct>; /** * Validate that a set of values matches a specific type. */ export declare function set(Element: Struct): Struct>; /** * Validate that a value is a string. */ export declare function string(): Struct; /** * Define a `Struct` instance with a type and validation function. */ export declare function struct(name: string, validator: Struct['validator']): Struct; /** * Validate that a value is a tuple with entries of specific types. */ export declare function tuple(Structs: StructTuple<[A]>): Struct; export declare function tuple(Structs: StructTuple<[A, B]>): Struct<[A, B]>; export declare function tuple(Structs: StructTuple<[A, B, C]>): Struct<[A, B, C]>; export declare function tuple(Structs: StructTuple<[A, B, C, D]>): Struct<[A, B, C, D]>; export declare function tuple(Structs: StructTuple<[A, B, C, D, E]>): Struct<[A, B, C, D, E]>; export declare function tuple(Structs: StructTuple<[A, B, C, D, E, F]>): Struct<[A, B, C, D, E, F]>; export declare function tuple(Structs: StructTuple<[A, B, C, D, E, F, G]>): Struct<[A, B, C, D, E, F, G]>; export declare function tuple(Structs: StructTuple<[A, B, C, D, E, F, G, H]>): Struct<[A, B, C, D, E, F, G, H]>; export declare function tuple(Structs: StructTuple<[A, B, C, D, E, F, G, H, I]>): Struct<[A, B, C, D, E, F, G, H, I]>; export declare function tuple(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J]>): Struct<[A, B, C, D, E, F, G, H, I, J]>; export declare function tuple(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K]>): Struct<[A, B, C, D, E, F, G, H, I, J, K]>; export declare function tuple(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L]>): Struct<[A, B, C, D, E, F, G, H, I, J, K, L]>; export declare function tuple(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L, M]>): Struct<[A, B, C, D, E, F, G, H, I, J, K, L, M]>; export declare function tuple(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L, M, N]>): Struct<[A, B, C, D, E, F, G, H, I, J, K, L, M, N]>; export declare function tuple(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O]>): Struct<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O]>; export declare function tuple(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P]>): Struct<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P]>; export declare function tuple(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q]>): Struct<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q]>; /** * Validate that a value matches a specific strutural interface, like the * structural typing that TypeScript uses. */ export declare function type>(Structs: V): Struct<{ [K in keyof V]: StructType; }>; /** * Validate that a value is one of a set of types. */ export declare function union(Structs: StructTuple<[A]>): Struct; export declare function union(Structs: StructTuple<[A, B]>): Struct; export declare function union(Structs: StructTuple<[A, B, C]>): Struct; export declare function union(Structs: StructTuple<[A, B, C, D]>): Struct; export declare function union(Structs: StructTuple<[A, B, C, D, E]>): Struct; export declare function union(Structs: StructTuple<[A, B, C, D, E, F]>): Struct; export declare function union(Structs: StructTuple<[A, B, C, D, E, F, G]>): Struct; export declare function union(Structs: StructTuple<[A, B, C, D, E, F, G, H]>): Struct; export declare function union(Structs: StructTuple<[A, B, C, D, E, F, G, H, I]>): Struct; export declare function union(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J]>): Struct; export declare function union(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K]>): Struct; export declare function union(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L]>): Struct; export declare function union(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L, M]>): Struct; export declare function union(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L, M, N]>): Struct; export declare function union(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O]>): Struct; export declare function union(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P]>): Struct; export declare function union(Structs: StructTuple<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q]>): Struct; export {}; //# sourceMappingURL=types.d.ts.map