-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
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
[Qwik] Zod async validation doesn't work #233
Labels
enhancement
New feature or request
Comments
I am not sure why I did not implement it with |
I plan to work on this issue today. |
fabian-hiller
added a commit
that referenced
this issue
Sep 2, 2024
A new version is available |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using custom async validation function in zod (using
.refine
) the form throws an error saying that.parseAsync
should be used for the validation.Async validation has many use cases. I personally encountered this issue while trying to implement username taken check during user registration.
The issue can presumably be traced to this file: /packages/qwik/src/utils/getParsedZodSchema.ts
In this file the
.safeParse
function is always used to parse the data, even when async validation is needed.It seems however that a very simple fix is possible:
We can always use the async version
.safeParseAsync
instead since the original function is always async anyway.As far as I know this approach has no downsides and successfully fixes the issue at hand.
The text was updated successfully, but these errors were encountered: