zod vs convex validators
Hi, we're internally discussing whether we should be defining our schema and interfaces with zod or convex validators. Thanks to the convex-helpers package it seems to be possible to use both.
Zod seems to have more granularity, works better with other libraries like AI SDKs and supports recursive types.
What's the main benefit of using validators or something else I might be missing?
2 Replies
it's totally cool to use zod
convex's basic validator types map to convex (database) types, which is a useful definition for cross-language compatibility, what's actually stored in the database, etc. but since in practice projects are in javascript/typescript right now (and not other languages), so leveraging zod to add more specific validations to rpc endpoints is a-ok
is there a way to do something like this in Zod? (this is with validators, and I thought it's something inspired by Zod)
ah got it, it's something like
options[0]
for picking a union and then shape
instead of .fields