I wasn't satisfied with zod* or class-validator* in NestJS projects, so I built this.
It's meant to be a complete solution for data transfer objects:
- A single construct for serialization and deserialization. zod and class-validator only handle parsing.
- Syntax and style closer to JSON Schema and OpenAPI for aligned mental models. zod uses chained methods, class-validator uses decorators.
- Straightforward way to integrate the HTTP context when parsing. Validation often depends on the requesting user.
- Static types by default. To get static types with zod, you must make an extra infer call. To get static types with class-validator, you must make a redundant type declaration.
*Both zod and class-validator are powerful and seem good for lots of use cases, just not my cup of tea for HTTP JSON APIs.
Also +1 Django REST Framework, it's been a huge productivity boost for us. For a small team dealing with a large codebase, its high-level abstractions provide lot of consistency while also providing enough flexibility for more specific use cases.
It's meant to be a complete solution for data transfer objects:
- A single construct for serialization and deserialization. zod and class-validator only handle parsing.
- Syntax and style closer to JSON Schema and OpenAPI for aligned mental models. zod uses chained methods, class-validator uses decorators.
- Straightforward way to integrate the HTTP context when parsing. Validation often depends on the requesting user.
- Static types by default. To get static types with zod, you must make an extra infer call. To get static types with class-validator, you must make a redundant type declaration.
*Both zod and class-validator are powerful and seem good for lots of use cases, just not my cup of tea for HTTP JSON APIs.