Use zod schemas for argument validation
I am using the zod helper library to use zod as validation but it I get an error when trying to use the zod schema from another file, but it works when writing the schema in the zMutation
error: Index signature for type 'string' is missing in type 'ZodObject. Is it possible to pass a defined schema or must all zod validation be done at that scope
3 Replies
How is
createTemplateSchema
defined? From the error message, it sounds like it's a z.object
when it should be a plain object
you are right it is a z object that i use for form validation on the front end. What is the best way to reuse this schema to work with convex ?
thanks for the reply btw!
@lee would I have to store the initial schema as a regular object with zod properties then also export a z.object of the same schema?
wondering if there is a better way to just just export one zod schema and type
You could try doing
{ args: createTemplateSchema.shape }
.
If that doesn't work, i would export both the plain object and the z.object