-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Custom validations not running if default types fail. #259
Comments
Having the same issue using 2.0.0-beta.29. The desired result is to have all errors output at the same time. |
This is a hard issue to solve. Refinements assume that the input has already been validated properly. It's why Zod is able to strongly type I could just run all refinements, even if type errors are already detected. Currently Zod doesn't catch errors thrown in refinements but it could. This way I could "safely" run all refinements. But you don't want all the refinement errors to appear if a completely incorrect value is passed into schema. For instance, it would be odd if you received a "Upper bound must be greater than lower bound" error if you tried |
Could refinements catch all errors except for that single case? |
Possibly. I could consider certain issues "fatal" and others non-fatal. For instance, the issue thrown by |
I've also faced this issue. A workaround which I found was to split the original schema into 2 and intersect them:
The main issue with this approach is that Also, I was wondering if I could use |
I also just run into this problem :(
Another idea that comes to my mind is to add a new method that would be like |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
May be a copy of #68 but I'm still seeing this issue. Using version: 2.0.0-beta.26
The text was updated successfully, but these errors were encountered: