UNPKG

2.72 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 * Fails validation for objects unknown to class-validator. Defaults to false.
64 *
65 * For instance, since a plain empty object has no annotations used for validation:
66 * - `validate({})` // passes
67 * - `validate({}, { forbidUnknownValues: true })` // fails.
68 * - `validate(new SomeAnnotatedEmptyClass(), { forbidUnknownValues: true })` // passes.
69 */
70 forbidUnknownValues?: boolean;
71 /**
72 * When set to true, validation of the given property will stop after encountering the first error. Defaults to false.
73 */
74 stopAtFirstError?: boolean;
75}