import { Struct, StructType, StructContext } from './struct'; declare type StructRecord = Record>; declare type StructTuple = { [K in keyof T]: Struct; }; /** * Validate any value. */ export declare function any(): Struct; /** * Validate that an array of values of a specific type. */ export declare function array(Element: Struct): Struct; /** * Validate that boolean values. */ export declare function boolean(): Struct; /** * Augment a `Struct` to add an additional coercion step to its input. */ export declare function coercion(struct: Struct, coercer: Struct['coercer']): 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; /** * Augment a struct to coerce a default value for missing values. * * Note: You must use `coerce(value, Struct)` on the value before validating it * to have the value defaulted! */ export declare function defaulted(S: Struct, fallback: any, strict?: true): 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; /** * Validate that a value is an instance of a class. */ export declare function instance(Class: T): Struct>; /** * Validate that a value is an integer. */ export declare function integer(): 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; /** * 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; /** * Augment a string or array struct to constrain its length to being between a * minimum and maximum size. */ export declare function length(S: Struct, min: number, max?: number): Struct; /** * Validate that a value is a specific constant. */ export declare function literal(constant: T): Struct; /** * Validate that a value is a map with specific key and value entries. */ export declare function map(Structs: StructTuple<[K, V]>): Struct>; /** * Validate that a value always fails. */ export declare function never(): Struct; /** * Validate that a value is a number. */ export declare function number(): Struct; /** * Validate that an object with specific entry values. */ export declare function object>(Structs: V): Struct<{ [K in keyof V]: StructType; }>; /** * Augment a struct to make it accept 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<{ [K in keyof V]?: StructType; }>; /** * Refine a string struct to match a specific regexp pattern. */ export declare function pattern(S: Struct, regexp: RegExp): Struct; /** * Validate that a value is a record with specific key and * value entries. */ export declare function record(Structs: StructTuple<[K, V]>): Struct>; /** * Augment a `Struct` to add an additional refinement to the validation. */ export declare function refinement(struct: Struct, type: string, refiner: Struct['refiner']): 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; /** * Coerce a string value to ensure it is trimmed. */ export declare function trimmed(S: Struct): Struct; /** * Validate that a value is a tuple with entries of specific types. */ export declare function tuple(Elements: StructTuple<[A]>): Struct<[A]>; export declare function tuple(Elements: StructTuple<[A, B]>): Struct<[A, B]>; export declare function tuple(Elements: StructTuple<[A, B, C]>): Struct<[A, B, C]>; export declare function tuple(Elements: StructTuple<[A, B, C, D]>): Struct<[A, B, C, D]>; export declare function tuple(Elements: StructTuple<[A, B, C, D, E]>): Struct<[A, B, C, D, E]>; /** * 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 an unknown value, accepting anything but not narrowing the type. */ export declare function unknown(): Struct; /** * 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 {};