You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd love to have support for .refine to generate corresponding if condition in the json schema
Example schema
constsomeSchema=z.object({enable: z.boolean().default(false),id: z.string().optional(),}).refine((data)=>{if(data.enable&&!data.id){returnfalse;}returntrue;},"id should be specified");
I don't think this is possible. The function defined in a refine could do anything, including side-effects. Your example is simple enough to be converted to a schema, yes - but that also means it could be expressed as a schema rather than in a refine. In this case, this would be the equivalent:
Hey, first of thanks for this amazing package 🙏🏽
I'd love to have support for
.refine
to generate correspondingif
condition in the json schemaExample schema
generated
expected
Let me know if there's a workaround for it too. Thanks!
The text was updated successfully, but these errors were encountered: