UNPKG

2.01 kBTypeScriptView Raw
1import { ErrorMessage, FieldMessageFactory, Location } from '../base';
2/**
3 * Creates a variant of `check()` that checks the given request locations.
4 *
5 * @example
6 * const checkBodyAndQuery = buildCheckFunction(['body', 'query']);
7 */
8export declare function buildCheckFunction(locations: Location[]): (fields?: string | string[], message?: FieldMessageFactory | ErrorMessage) => import("..").ValidationChain;
9/**
10 * Creates a middleware/validation chain for one or more fields that may be located in
11 * any of the following:
12 *
13 * - `req.body`
14 * - `req.cookies`
15 * - `req.headers`
16 * - `req.params`
17 * - `req.query`
18 *
19 * @param fields a string or array of field names to validate/sanitize
20 * @param message an error message to use when failed validations don't specify a custom message.
21 * Defaults to `Invalid Value`.
22 */
23export declare const check: (fields?: string | string[], message?: FieldMessageFactory | ErrorMessage) => import("..").ValidationChain;
24/**
25 * Same as {@link check()}, but only validates `req.body`.
26 */
27export declare const body: (fields?: string | string[], message?: FieldMessageFactory | ErrorMessage) => import("..").ValidationChain;
28/**
29 * Same as {@link check()}, but only validates `req.cookies`.
30 */
31export declare const cookie: (fields?: string | string[], message?: FieldMessageFactory | ErrorMessage) => import("..").ValidationChain;
32/**
33 * Same as {@link check()}, but only validates `req.headers`.
34 */
35export declare const header: (fields?: string | string[], message?: FieldMessageFactory | ErrorMessage) => import("..").ValidationChain;
36/**
37 * Same as {@link check()}, but only validates `req.params`.
38 */
39export declare const param: (fields?: string | string[], message?: FieldMessageFactory | ErrorMessage) => import("..").ValidationChain;
40/**
41 * Same as {@link check()}, but only validates `req.query`.
42 */
43export declare const query: (fields?: string | string[], message?: FieldMessageFactory | ErrorMessage) => import("..").ValidationChain;