4 ms·
Zod is great, but JSON-schema is my pick because it is easily serialized. So a client can query for the schema of the data it should send or receive, including
by evv 4y ago
Zod is great, but JSON-schema is my pick because it is easily serialized. So a client can query for the schema of the data it should send or receive, including descriptions/metadata that is useful for presenting a UI.
- vlovich123 4y agoZod to JSON schema is a thing so I think that solves your problem, no? https://www.npmjs.com/package/zod-to-json-schema https://www.npmjs.com/package/zod-to-json-schema
- tmerse 4y agoYou happen to know if there are libs/utils to achieve the reverse (JSON-schema -> zod)? Could be useful for one of my usecases (form validation via rules recievd as JSON)
- evv 4y agoI didn't know about this! But on the client I would use a JSON-schema validator anyways, otherwise I'd need something like "json-schema-to-zod"? Seems like a roundabout way to address my problem