-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
49 lines (48 loc) · 1.14 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { Request, Response, NextFunction } from 'express';
import { Options } from 'ajv';
/**
* Validator settings
*/
export type ValidatorOptions = {
/**
* - Custom error handler
*/
errorHandler: Function;
/**
* - Ajv config object
*/
ajvConfig: Options;
};
/**
* Request validation configuration object
*/
export type RequestValidationConfig = {
/**
* - Indicates if request body will be validated
*/
body?: boolean;
/**
* - Indicates if path params will be validated
*/
params?: boolean;
/**
* - Indicates if request headers will be validated
*/
headers?: boolean;
/**
* - Indicates if query params will be validated
*/
query?: boolean;
/**
* - Indicates if required fields will be validated
*/
required?: boolean;
};
export type ValidatorInstance = {
/**
* - Method to validate the request
*/
validateRequest: (options?: RequestValidationConfig) => (req: Request, res: Response, next: NextFunction) => void;
validateResponse: (payload: any, req: Request, status?: number) => boolean;
};
export function init(openApiDef: any, options?: ValidatorOptions): ValidatorInstance;