Questions about validation in Multi-step Forms
Hi,
I would like to ask some questions about validation.
1. Is it possible to validate onScreen fields only when calling next function in Multi-step form?
I am transforming paper forms to e-forms. Most of our forms has over 300 fields.
My extreme case is the form has 8 steps, and each step has around 50 - 80 fields.
I found that the validate function will iterate all fields and do the validations.
Let's say I am in Step 3, and call the next function, the screen will freeze around 4 - 5 seconds and wait for all field validations(with yup schema) complete.
So I wonder if it could be possible to validate onScreen fields only when calling next function?
2. How could I know the status after the validation / next function?
For my use case, I want to scroll to the error message element after the validation, but it seems that there is no metadata to know when the validation is completed.
It would be nice if I can know status after validation / next function.
Thank you.
Ahh so I believe it will only validate "onScreen" fields but not if you pass a full yup schema.
Nevermind i was wrong https://github.com/joepuzzo/informed/blob/master/src/FormController.js#L312
Turns out I do validate all fields but only include them as part of the form errors if relevant. I could update this but it wont help with form level yup validation as its a single schema.
Are you passing form level or field level yup schemas?
Sorry for late reply.
Yes. I am using field level yup schemas.
Try this in new version. I have done lots of work to improve validation