1 | import { Struct } from './struct';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | export declare type Context = {
|
7 | value: any;
|
8 | type: string;
|
9 | refinement: string | undefined;
|
10 | branch: Array<any>;
|
11 | path: Array<string | number>;
|
12 | fail: (props?: Partial<Failure>) => Failure;
|
13 | check: <T, S>(value: any, struct: Struct<T, S>, parent?: any, key?: string | number) => Iterable<Failure>;
|
14 | };
|
15 |
|
16 |
|
17 |
|
18 | export declare type Failure = {
|
19 | value: Context['value'];
|
20 | type: Context['type'];
|
21 | refinement: Context['refinement'];
|
22 | branch: Context['branch'];
|
23 | path: Context['path'];
|
24 | [key: string]: any;
|
25 | };
|
26 |
|
27 |
|
28 |
|
29 | export declare type Infer<T extends Struct<any, any>> = T['TYPE'];
|
30 |
|
31 |
|
32 |
|
33 | export declare type Result = boolean | Iterable<Failure>;
|
34 | export declare type Coercer = (value: unknown) => unknown;
|
35 | export declare type Validator = (value: unknown, context: Context) => Result;
|
36 | export declare type Refiner<T> = (value: T, context: Context) => Result;
|