- Published on
Zod
- Authors
- Name
- Lucas Floriani
- @lucasfloriani13
Zod
Its a library that is almost like a fusion between types we create and a validation library like Yup, the difference is that it will validates the moment you put a value inside the variable instead of later when you invoke the validation.
It has a lot of integrations and helper libraries that can complement your DX with it
Interesting extensions
- zod-to-openapi: It registers some types and generates OpenAPI documentation from them
- zod-validation-error: Generate user-friendly error messages from
ZodError
- zod-dto: Generate Nest.js DTOs from a Zod schema.
- ts-to-zod: Convert TypeScript definitions into Zod schemas.
- zod-prisma: Generate Zod schemas from your Prisma schema.
- Supervillain: Generate Zod schemas from your Go structs.
Conclusion
After some discussions I approved the usage of this library instead of using Yup and creating Types manually