Closed benjaminkwokhuen closed 1 year ago
Good question. I tend to always use some separate form validation library for this, so I'm not really sure.
But it should be possible to use volatile state for the form state, and views for validation. You could probably defer updating the request model to when you are ready to save the form.
That's what I ended up doing, using react-hook-form
and yup
to do validation.
However, the main issue with this approach is that I need to maintain 2 sets of model (one from yup object schema, one from createMutation model).
It would be great if there's a way to just have one model define along with the validation and use it to take care of everything.
Check out mst-validation :)
Just wondering how can I use createMutation to achieve form validation. Ideally, I want to use the mutation model to store the field values, but I also want to be able to validate user input on change.