You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/techniques/validation.md
+34-1Lines changed: 34 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,21 @@ In addition to these, all `class-validator` options (inherited from the `Validat
42
42
<th>Type</th>
43
43
<th>Description</th>
44
44
</tr>
45
+
<tr>
46
+
<td><code>enableDebugMessages</code></td>
47
+
<td><code>boolean</code></td>
48
+
<td>If set to true, validator will print extra warning messages to the console when something is not right.</td>
49
+
</tr>
50
+
<tr>
51
+
<td><code>skipUndefinedProperties</code></td>
52
+
<td><code>boolean</code></td>
53
+
<td>If set to true, validator will skip validation of all properties that are null in the validating object.</td>
54
+
</tr>
55
+
<tr>
56
+
<td><code>skipNullProperties</code></td>
57
+
<td><code>boolean</code></td>
58
+
<td> If set to true, validator will skip validation of all properties that are null or undefined in the validating object.</td>
59
+
</tr>
45
60
<tr>
46
61
<td><code>skipMissingProperties</code></td>
47
62
<td><code>boolean</code></td>
@@ -82,6 +97,17 @@ In addition to these, all `class-validator` options (inherited from the `Validat
82
97
<td><code>string[]</code></td>
83
98
<td>Groups to be used during validation of the object.</td>
84
99
</tr>
100
+
<tr>
101
+
<td><code>always</code></td>
102
+
<td><code>boolean</code></td>
103
+
<td>Set default for <code>always</code> option of decorators. Default can be overridden in decorator options</td>
104
+
</tr>
105
+
106
+
<tr>
107
+
<td><code>strictGroups</code></td>
108
+
<td><code>boolean</code></td>
109
+
<td>If <code>groups</code> is not given or is empty, ignore decorators with at least one group.</td>
110
+
</tr>
85
111
<tr>
86
112
<td><code>dismissDefaultMessages</code></td>
87
113
<td><code>boolean</code></td>
@@ -98,11 +124,15 @@ In addition to these, all `class-validator` options (inherited from the `Validat
98
124
<td><code>boolean</code></td>
99
125
<td>Indicates if validated value should be exposed in <code>ValidationError</code>.</td>
100
126
</tr>
127
+
<tr>
128
+
<td><code>stopAtFirstError</code></td>
129
+
<td><code>boolean</code></td>
130
+
<td>When set to true, validation of the given property will stop after encountering the first error. Defaults to false.</td>
131
+
</tr>
101
132
</table>
102
133
103
134
> info **Notice** Find more information about the `class-validator` package in its [repository](https://github.com/typestack/class-validator).
104
135
105
-
106
136
#### Auto-validation
107
137
108
138
We'll start by binding `ValidationPipe` at the application level, thus ensuring all endpoints are protected from receiving incorrect data.
@@ -287,6 +317,7 @@ export class UpdateCatDto extends PartialType(CreateCatDto) {}
287
317
```
288
318
289
319
> info **Hint** The `PartialType()` function is imported from the `@nestjs/mapped-types` package.
320
+
290
321
The `PickType()` function constructs a new type (class) by picking a set of properties from an input type. For example, suppose we start with a type like:
291
322
292
323
```typescript
@@ -304,6 +335,7 @@ export class UpdateCatAgeDto extends PickType(CreateCatDto, ['age'] as const) {}
304
335
```
305
336
306
337
> info **Hint** The `PickType()` function is imported from the `@nestjs/mapped-types` package.
338
+
307
339
The `OmitType()` function constructs a type by picking all properties from an input type and then removing a particular set of keys. For example, suppose we start with a type like:
308
340
309
341
```typescript
@@ -321,6 +353,7 @@ export class UpdateCatDto extends OmitType(CreateCatDto, ['name'] as const) {}
321
353
```
322
354
323
355
> info **Hint** The `OmitType()` function is imported from the `@nestjs/mapped-types` package.
356
+
324
357
The `IntersectionType()` function combines two types into one new type (class). For example, suppose we start with two types like:
0 commit comments