UNPKG

915 BTypeScriptView Raw
1import { Location, Request } from './base';
2export type MatchedDataOptions = {
3 /**
4 * Whether the value returned by `matchedData()` should include data deemed optional.
5 * @default false
6 */
7 includeOptionals: boolean;
8 /**
9 * An array of locations in the request to extract the data from.
10 */
11 locations: Location[];
12 /**
13 * Whether the value returned by `matchedData()` should include only values that have passed
14 * validation.
15 * @default true
16 */
17 onlyValidData: boolean;
18};
19/**
20 * Extracts data validated or sanitized from the request, and builds an object with them.
21 *
22 * @param req the express request object
23 * @param options
24 * @returns an object of data that's been validated or sanitized in the passed request
25 */
26export declare function matchedData<T extends object = Record<string, any>>(req: Request, options?: Partial<MatchedDataOptions>): T;