Skip to content

Commit b474d2f

Browse files
Update custom-decorators.md
1 parent 3db9ab3 commit b474d2f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

content/custom-decorators.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,19 @@ Nest treats custom param decorators in the same fashion as the built-in ones (`@
161161
```typescript
162162
@@filename()
163163
@Get()
164-
async findOne(@User(new ValidationPipe()) user: UserEntity) {
164+
async findOne(@User(new ValidationPipe({ validateCustomDecorators: true })) user: UserEntity) {
165165
console.log(user);
166166
}
167167
@@switch
168168
@Get()
169-
@Bind(User(new ValidationPipe()))
169+
@Bind(User(new ValidationPipe({ validateCustomDecorators: true })))
170170
async findOne(user) {
171171
console.log(user);
172172
}
173173
```
174174

175+
> info **Hint** Note that `validateCustomDecorators` option must be set to true. `ValidationPipe` does not validate arguments annotated with the custom decorators by default.
176+
175177
#### Decorator composition
176178

177179
Nest provides a helper method to compose multiple decorators. For example, suppose you want to combine all decorators related to authentication into a single decorator. This could be done with the following construction:

0 commit comments

Comments
 (0)