1 | import { Sanitizers } from '../chain/sanitizers';
|
2 | import { Validators } from '../chain/validators';
|
3 | import { CustomValidator, DynamicMessageCreator, Location, Request } from '../base';
|
4 | import { ValidationChain } from '../chain';
|
5 | import { Optional } from '../context';
|
6 | import { ResultWithContext } from '../chain/context-runner-impl';
|
7 | declare type ValidatorSchemaOptions<K extends keyof Validators<any>> = true | {
|
8 | options?: Parameters<Validators<any>[K]> | Parameters<Validators<any>[K]>[0];
|
9 | errorMessage?: DynamicMessageCreator | any;
|
10 | negated?: boolean;
|
11 | bail?: boolean;
|
12 | if?: CustomValidator | ValidationChain | CustomValidator;
|
13 | };
|
14 | export declare type ValidatorsSchema = {
|
15 | [K in keyof Validators<any>]?: ValidatorSchemaOptions<K>;
|
16 | };
|
17 | declare type SanitizerSchemaOptions<K extends keyof Sanitizers<any>> = true | {
|
18 | options?: Parameters<Sanitizers<any>[K]> | Parameters<Sanitizers<any>[K]>[0];
|
19 | };
|
20 | export declare type SanitizersSchema = {
|
21 | [K in keyof Sanitizers<any>]?: SanitizerSchemaOptions<K>;
|
22 | };
|
23 | declare type InternalParamSchema = ValidatorsSchema & SanitizersSchema;
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | export declare type ParamSchema = InternalParamSchema & {
|
29 | in?: Location | Location[];
|
30 | errorMessage?: DynamicMessageCreator | any;
|
31 | optional?: true | {
|
32 | options?: Partial<Optional>;
|
33 | };
|
34 | };
|
35 |
|
36 |
|
37 |
|
38 | export declare type ValidationParamSchema = ParamSchema;
|
39 |
|
40 |
|
41 |
|
42 | export declare type Schema = Record<string, ParamSchema>;
|
43 |
|
44 |
|
45 |
|
46 | export declare type ValidationSchema = Schema;
|
47 | export declare function checkSchema(schema: Schema, defaultLocations?: Location[]): ValidationChain[] & {
|
48 | run: (req: Request) => Promise<ResultWithContext[]>;
|
49 | };
|
50 | export {};
|