File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -294,6 +294,22 @@ In this case, we want to bind the pipe at the method call level. In our current
294
294
2 . Pass the context-specific Joi schema in the class constructor of the pipe
295
295
3 . Bind the pipe to the method
296
296
297
+ Joi schema example:
298
+
299
+ ``` typescript
300
+ const createCatSchema = Joi .object ({
301
+ name: Joi .string ().required (),
302
+ age: Joi .number ().required (),
303
+ breed: Joi .string ().required (),
304
+ })
305
+
306
+ export interface CreateCatDto {
307
+ name: string ;
308
+ age: number ;
309
+ breed: string ;
310
+ }
311
+ ```
312
+
297
313
We do that using the ` @UsePipes() ` decorator as shown below:
298
314
299
315
``` typescript
@@ -314,6 +330,7 @@ async create(createCatDto) {
314
330
315
331
> info ** Hint** The ` @UsePipes() ` decorator is imported from the ` @nestjs/common ` package.
316
332
333
+
317
334
#### Class validator
318
335
319
336
> warning ** Warning** The techniques in this section require TypeScript, and are not available if your app is written using vanilla JavaScript.
You can’t perform that action at this time.
0 commit comments