Schema
Library Support
@webroute/schema
currently supports the following libraries.
Infer | Parse | Parser | Formatter | Discriminator | JSON Schema | |
---|---|---|---|---|---|---|
Zod | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Yup | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Joi | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Valibot | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
TypeBox | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Superstruct | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Runtypes | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Installation
Bear in mind the actual validation library must be installed to work properly.
For example: @webroute/schema/zod
-> npm i zod
Usage
Under the @webroute/schema/<library>
packages, you can find helpers for the given validator library.
For example, we can import the zod
helpers via.