UNPKG

2.42 kBTypeScriptView Raw
1/**
2 * Options passed to validator during validation.
3 */
4export interface ValidatorOptions {
5 /**
6 * If set to true then class-validator will print extra warning messages to the console when something is not right.
7 */
8 enableDebugMessages?: boolean;
9 /**
10 * If set to true then validator will skip validation of all properties that are undefined in the validating object.
11 */
12 skipUndefinedProperties?: boolean;
13 /**
14 * If set to true then validator will skip validation of all properties that are null in the validating object.
15 */
16 skipNullProperties?: boolean;
17 /**
18 * If set to true then validator will skip validation of all properties that are null or undefined in the validating object.
19 */
20 skipMissingProperties?: boolean;
21 /**
22 * If set to true validator will strip validated object of any properties that do not have any decorators.
23 *
24 * Tip: if no other decorator is suitable for your property use @Allow decorator.
25 */
26 whitelist?: boolean;
27 /**
28 * If set to true, instead of stripping non-whitelisted properties validator will throw an error
29 */
30 forbidNonWhitelisted?: boolean;
31 /**
32 * Groups to be used during validation of the object.
33 */
34 groups?: string[];
35 /**
36 * Set default for `always` option of decorators. Default can be overridden in decorator options.
37 */
38 always?: boolean;
39 /**
40 * If [groups]{@link ValidatorOptions#groups} is not given or is empty,
41 * ignore decorators with at least one group.
42 */
43 strictGroups?: boolean;
44 /**
45 * If set to true, the validation will not use default messages.
46 * Error message always will be undefined if its not explicitly set.
47 */
48 dismissDefaultMessages?: boolean;
49 /**
50 * ValidationError special options.
51 */
52 validationError?: {
53 /**
54 * Indicates if target should be exposed in ValidationError.
55 */
56 target?: boolean;
57 /**
58 * Indicates if validated value should be exposed in ValidationError.
59 */
60 value?: boolean;
61 };
62 /**
63 * Settings true will cause fail validation of unknown objects.
64 */
65 forbidUnknownValues?: boolean;
66 /**
67 * When set to true, validation of the given property will stop after encountering the first error. Defaults to false.
68 */
69 stopAtFirstError?: boolean;
70}