UNPKG

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