1 comment

[ 3.4 ms ] story [ 15.2 ms ] thread
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.