-
-
Notifications
You must be signed in to change notification settings - Fork 170
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
Zod preprocess does not generate error #635
Comments
I have the same issue here. Interestingly, it works if const SignupSchema = z.object({
- ageCoerce,
- agePreprocess,
+ agePreprocess,
+ ageCoerce,
}); |
That is interesting. I can confirm the same behaviour. |
I have the same issue. Codesandbox link (Changed zod version from 3.22.3 to 3.21.4) Update: |
We have found the same behavior with the fields being order-depdendent. We replaced our preprocessors with transforms, and they work similarly to how the preprocessors worked in 3.21.4. Downgrading is not an option for us due to a CVE in 3.21.4 our cyber team flagged. |
The issue commented on #635 (comment) has been resolved by the following pr fix for zod, so I would like to share it. And this fix is included in v3.23.0 of zod. |
@stackline Confirmed as fixed, thanks! |
Describe the bug
Using z.preprocess() instead of z.coerce() in a validation schema does not generate an error. When using zod directly, both of these approaches generate the same error.
To Reproduce
Steps to reproduce the behavior:
Codesandbox link (Required)
https://codesandbox.io/s/react-hook-form-zod-preprocess-mn8sy4?file=/src/index.js
Expected behavior
An error should be generated
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: