UNPKG

1.53 kBTypeScriptView Raw
1import { ReadonlyContext } from './context';
2export interface Request {
3 [k: string]: any;
4 body?: any;
5 cookies?: Record<string, any>;
6 headers?: Record<string, any>;
7 params?: Record<string, any>;
8 query?: Record<string, any>;
9}
10export declare type Middleware = (req: Request, res: any, next: (err?: any) => void) => void;
11export declare type Location = 'body' | 'cookies' | 'headers' | 'params' | 'query';
12export declare type Meta = {
13 req: Request;
14 location: Location;
15 path: string;
16};
17export declare type CustomValidator = (input: any, meta: Meta) => any;
18export declare type StandardValidator = (input: string, ...options: any[]) => boolean;
19export declare type CustomSanitizer = (input: any, meta: Meta) => any;
20export declare type StandardSanitizer = (input: string, ...options: any[]) => any;
21export declare type DynamicMessageCreator = (value: any, meta: Meta) => any;
22export interface FieldInstance {
23 path: string;
24 originalPath: string;
25 location: Location;
26 value: any;
27 originalValue: any;
28}
29export declare type ValidationError = {
30 param: '_error';
31 msg: any;
32 nestedErrors: ValidationError[];
33 location?: undefined;
34 value?: undefined;
35} | {
36 location: Location;
37 param: string;
38 value: any;
39 msg: any;
40 nestedErrors?: unknown[];
41};
42export declare const contextsKey = "express-validator#contexts";
43export interface InternalRequest extends Request {
44 [contextsKey]?: ReadonlyContext[];
45}
46export declare class ValidationHalt extends Error {
47}