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
|[nestjs-zod](https://github.com/risenforces/nestjs-zod)| A tools for integrating Zod into your NestJS application |
29
+
|[nestjs-zod-prisma](https://github.com/risenforces/nestjs-zod-prisma)| Generate Zod schemas from your Prisma schema |
30
30
31
31
## Core library features
32
32
@@ -54,10 +54,11 @@ yarn add nestjs-zod zod
54
54
```
55
55
56
56
Peer dependencies:
57
+
57
58
-`zod` - `>= 3.14.3`
58
-
-`@nestjs/common` - `>= 8.0.0` (required on server side)
59
-
-`@nestjs/core` - `>= 8.0.0` (required on server side)
60
-
-`@nestjs/swagger` - `>= 5.0.0` (only when using `patchNestJsSwagger`)
59
+
-`@nestjs/common` - `>= 8.0.0` (required on server side)
60
+
-`@nestjs/core` - `>= 8.0.0` (required on server side)
61
+
-`@nestjs/swagger` - `>= 5.0.0` (only when using `patchNestJsSwagger`)
61
62
62
63
All peer dependencies are marked as optional for better client side usage, but you need to install required ones when using `nestjs-zod` on server side.
63
64
@@ -73,6 +74,7 @@ All peer dependencies are marked as optional for better client side usage, but y
returnthis.userService.findOne(id) // --> The native service method returns { username: string, password: string by default }
373
+
}
374
+
}
375
+
```
376
+
377
+
In the above example, despite the `userService.findOne` method returns `password`, the `password` property will be stripped out thanks to the `@ZodResponseDto` decorator.
378
+
324
379
## Extended Zod
325
380
326
381
As you learned in [Writing Zod Schemas](#writing-zod-schemas) section, `nestjs-zod` provides a special version of Zod. It helps you to validate the user input more accurately by using our custom schemas and methods.
@@ -365,31 +420,37 @@ z.dateString().weekend()
365
420
```
366
421
367
422
Valid `date` format examples:
423
+
368
424
-`2022-05-15`
369
425
370
426
Valid `date-time` format examples:
427
+
371
428
-`2022-05-02:08:33Z`
372
429
-`2022-05-02:08:33.000Z`
373
430
-`2022-05-02:08:33+00:00`
374
431
-`2022-05-02:08:33-00:00`
375
432
-`2022-05-02:08:33.000+00:00`
376
433
377
434
Errors:
435
+
378
436
-`invalid_date_string` - invalid date
379
437
380
438
-`invalid_date_string_format` - wrong format
381
439
382
440
Payload:
441
+
383
442
-`expected` - `'date' | 'date-time'`
384
443
385
444
-`invalid_date_string_direction` - not past/future
0 commit comments