Skip to content

Commit 16de88b

Browse files
Merge pull request #2047 from xiaohanxu-nick/docs(validation)/add-more-class-validator-options
docs(validation): add more class validator options
2 parents 82db495 + de46c13 commit 16de88b

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

content/techniques/validation.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,21 @@ In addition to these, all `class-validator` options (inherited from the `Validat
4242
<th>Type</th>
4343
<th>Description</th>
4444
</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>
4560
<tr>
4661
<td><code>skipMissingProperties</code></td>
4762
<td><code>boolean</code></td>
@@ -82,6 +97,17 @@ In addition to these, all `class-validator` options (inherited from the `Validat
8297
<td><code>string[]</code></td>
8398
<td>Groups to be used during validation of the object.</td>
8499
</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>
85111
<tr>
86112
<td><code>dismissDefaultMessages</code></td>
87113
<td><code>boolean</code></td>
@@ -98,11 +124,15 @@ In addition to these, all `class-validator` options (inherited from the `Validat
98124
<td><code>boolean</code></td>
99125
<td>Indicates if validated value should be exposed in <code>ValidationError</code>.</td>
100126
</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>
101132
</table>
102133

103134
> info **Notice** Find more information about the `class-validator` package in its [repository](https://github.com/typestack/class-validator).
104135
105-
106136
#### Auto-validation
107137

108138
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) {}
287317
```
288318

289319
> info **Hint** The `PartialType()` function is imported from the `@nestjs/mapped-types` package.
320+
290321
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:
291322

292323
```typescript
@@ -304,6 +335,7 @@ export class UpdateCatAgeDto extends PickType(CreateCatDto, ['age'] as const) {}
304335
```
305336

306337
> info **Hint** The `PickType()` function is imported from the `@nestjs/mapped-types` package.
338+
307339
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:
308340

309341
```typescript
@@ -321,6 +353,7 @@ export class UpdateCatDto extends OmitType(CreateCatDto, ['name'] as const) {}
321353
```
322354

323355
> info **Hint** The `OmitType()` function is imported from the `@nestjs/mapped-types` package.
356+
324357
The `IntersectionType()` function combines two types into one new type (class). For example, suppose we start with two types like:
325358

326359
```typescript

0 commit comments

Comments
 (0)