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
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:
I am not sure why I did not implement it with .safeParseAsync. I think there was a reason, but I am not sure anymore. I will see if I can change it to .safeParseAsync and release a new version. As a workaround you can simply copy the code, change it to the async version and use your own adapter until the new version is available.
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: