We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
undefined
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
To reproduce, use https://github.com/Firfi/zod-to-json-schema-preprocess-bug
For such code as
const idParser = z.preprocess( (uuid) => { if (typeof uuid !== 'string') throw new Error(`Expected string, got ${typeof uuid}: ${uuid}`); const [type, id] = uuid.split('SEPARATOR'); return { type, id }; }, z.object({ type: z.string(), id: z.string() }));
zodToJsonSchema(idParser) will be evaluated all right, however
zodToJsonSchema(idParser)
if I do
const idParser2 = z.object({ id: idParser })
zodToJsonSchema(idParser2) starts passing undefined into preprocess (as my uuid var)
zodToJsonSchema(idParser2)
uuid
I wonder if that's expected behaviour and why it happens only when a parser is used inside z.object
z.object
The text was updated successfully, but these errors were encountered:
isOptional
Hello @Firfi, thanks for logging an issue. This looks like an internal Zod bug. I've logged an issue here: colinhacks/zod#1460
Sorry, something went wrong.
I've added a note about this issue in the readme. Closing this for lack of activity in the meantime but let's keep an eye on the issue in Zod
No branches or pull requests
To reproduce, use https://github.com/Firfi/zod-to-json-schema-preprocess-bug
For such code as
zodToJsonSchema(idParser)
will be evaluated all right, howeverif I do
zodToJsonSchema(idParser2)
starts passingundefined
into preprocess (as myuuid
var)I wonder if that's expected behaviour and why it happens only when a parser is used inside
z.object
The text was updated successfully, but these errors were encountered: