-
Notifications
You must be signed in to change notification settings - Fork 809
/
Copy pathValidatorOptions.ts
88 lines (75 loc) · 2.51 KB
/
ValidatorOptions.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* Options passed to validator during validation.
*/
export interface ValidatorOptions {
/**
* If set to true then class-validator will print extra warning messages to the console when something is not right.
*/
enableDebugMessages?: boolean;
/**
* If set to true then validator will skip validation of all properties that are undefined in the validating object.
*/
skipUndefinedProperties?: boolean;
/**
* If set to true then validator will skip validation of all properties that are null in the validating object.
*/
skipNullProperties?: boolean;
/**
* If set to true then validator will skip validation of all properties that are null or undefined in the validating object.
*/
skipMissingProperties?: boolean;
/**
* If set to true validator will strip validated object of any properties that do not have any decorators.
*
* Tip: if no other decorator is suitable for your property use @Allow decorator.
*/
whitelist?: boolean;
/**
* If set to true, instead of stripping non-whitelisted properties validator will throw an error
*/
forbidNonWhitelisted?: boolean;
/**
* Groups to be used during validation of the object.
*/
groups?: string[];
/**
* Set default for `always` option of decorators. Default can be overridden in decorator options.
*/
always?: boolean;
/**
* If [groups]{@link ValidatorOptions#groups} is not given or is empty,
* ignore decorators with at least one group.
*/
strictGroups?: boolean;
/**
* If set to true, the validation will not use default messages.
* Error message always will be undefined if its not explicitly set.
*/
dismissDefaultMessages?: boolean;
/**
* ValidationError special options.
*/
validationError?: {
/**
* Indicates if target should be exposed in ValidationError.
*/
target?: boolean;
/**
* Indicates if validated value should be exposed in ValidationError.
*/
value?: boolean;
};
/**
* Fails validation for objects unknown to class-validator. Defaults to false.
*
* For instance, since a plain empty object has no annotations used for validation:
* - `validate({})` // passes
* - `validate({}, { forbidUnknownValues: true })` // fails.
* - `validate(new SomeAnnotatedEmptyClass(), { forbidUnknownValues: true })` // passes.
*/
forbidUnknownValues?: boolean;
/**
* When set to true, validation of the given property will stop after encountering the first error. Defaults to false.
*/
stopAtFirstError?: boolean;
}