informed icon indicating copy to clipboard operation
informed copied to clipboard

Questions about validation in Multi-step Forms

Open calebklc opened this issue 6 years ago • 5 comments

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.

calebklc avatar Mar 17 '20 06:03 calebklc

Ahh so I believe it will only validate "onScreen" fields but not if you pass a full yup schema.

joepuzzo avatar Apr 01 '20 15:04 joepuzzo

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.

joepuzzo avatar Apr 01 '20 15:04 joepuzzo

Are you passing form level or field level yup schemas?

joepuzzo avatar Apr 01 '20 15:04 joepuzzo

Sorry for late reply.

Yes. I am using field level yup schemas.

calebklc avatar May 12 '20 02:05 calebklc

Try this in new version. I have done lots of work to improve validation

joepuzzo avatar Dec 13 '21 17:12 joepuzzo