UNPKG

842 BTypeScriptView Raw
1import { Request, ValidationError } from '../base';
2import { ReadonlyContext } from '../context';
3import { Result } from '../validation-result';
4export type ContextRunningOptions = {
5 /**
6 * Defines whether errors and sanitization should be persisted to `req`.
7 * @default false
8 */
9 dryRun?: boolean;
10};
11export interface ResultWithContext extends Result<ValidationError> {
12 readonly context: ReadonlyContext;
13}
14export interface ContextRunner {
15 /**
16 * Runs the current validation chain.
17 * @param req the express request to validate
18 * @param options an object of options to customize how the chain will be run
19 * @returns a promise for a {@link Result} that resolves when the validation chain has finished
20 */
21 run(req: Request, options?: ContextRunningOptions): Promise<ResultWithContext>;
22}