We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
.optional()
.refine()
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
Description On a zod schema, when using .optional() with .refine(), the method superValidate(zod(schema) fails with error:
superValidate(zod(schema)
Async refinement encountered during synchronous parse operation. Use .parseAsync instead.
If applicable, a MRE
// file: +page.server.ts import { superValidate } from "sveltekit-superforms/server"; import { zod } from "sveltekit-superforms/adapters"; import { z } from "zod"; const schema = z.object({ name: z.string().min(1), email: z .string() .optional() .refine(async () => Promise.resolve(true)), }); export const load = async () => { return { form: await superValidate(zod(schema)) }; };
// file: +page.svelte // empty, not even implemented
The text was updated successfully, but these errors were encountered:
That is strange, since safeParseAsync is used in the adapter. Does it work when you remove optional?
safeParseAsync
Sorry, something went wrong.
Thank you for your message :)
Yes, it works when removing .optional()
It looks like a problem with Zod and the JSON Schema generator: colinhacks/zod#1460
No branches or pull requests
Description
On a zod schema, when using
.optional()
with.refine()
, the methodsuperValidate(zod(schema)
fails with error:If applicable, a MRE
The text was updated successfully, but these errors were encountered: