Replies: 2 comments 6 replies
-
Your |
Beta Was this translation helpful? Give feedback.
-
This is a very common scenario for me too. Here is a simple but typical exemple : valibot playground @fabian-hiller Do you have any new recommendation for this use case? specially with the new v0.31 in mind? |
Beta Was this translation helpful? Give feedback.
-
I believe the only available method of cross-field validation does not execute until all individual property schemas are valid (not including value validations). In the case of form validation, this isn't always reasonable.
It is possible to work around this in cases where all other properties have defaults or are otherwise not required and where it is reasonable to always start with a fully valid schema.
My goal is to ensure that user feedback in forms is consistent and that errors in form input can be exposed immediately when appropriate. In particular, having a user progress through a form and end up with surprise validations leads to poor UX.
Please see my extremely naive implementation here (switch to the
Immediately Evaluated Pipe
tab): https://codesandbox.io/p/devbox/react-mui-react-hook-form-valibot-hddfsq?file=%2Fsrc%2Fvalidation%2Frefine.ts%3A1%2C1-34%2C1The
refine
utility intentionally performs validation against the input. It doesn't cover all potentials, I've probably done something terrible, and it certainly could be better composed, but it does function for this limited example.Beta Was this translation helpful? Give feedback.
All reactions