React-jsonschema-form: Add support for disabling all validation until form submit

Created on 8 Apr 2016  路  7Comments  路  Source: rjsf-team/react-jsonschema-form

Prerequisites

If you pass down formData from a parent component to the form, props can update when the user is editing the form and, according to the docs (and real life experience), make liveValidate=false futile since;

By default, form data are only validated when the form is submitted or when a new formData prop is passed to the Form component.

There should be a way to only validate the form onSubmit, so maybe add propValidate=true (or a similarly but better named prop) if I actually want the form to validate automatically when props change.

Version

"react-jsonschema-form": "^0.23.0"

bug

All 7 comments

What I had in mind is something like this: c28eb806eb1b17f78cf99948662a9efd93a08dc0

Feel free to take a look (and maybe come up with a better name for the prop)!

Would it make sense to leverage the existing liveValidate prop instead of introducing a new one?

Absolutely! Since liveValidate never worked as advertised for me (it always validated, even when set to false) I assumed there was a use case for it and I needed a new prop to actually force the validation to only occur on submit.

Here I use the liveValidate prop instead and everything works in my setup: cd819777337f736e9283ce72b18505db5ec34c73

It will change the behavior for people using 0.21.0+ though since it won't liveValidate when props change unless liveValidate is true.

Sounds great. Could you please send a PR, along with some tests? I'll issue a 0.23.1 immediately after. Thanks!

Will do! It will have to be next week though.

No problem, we're not in a hurry here :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jabaren picture jabaren  路  3Comments

Eric24 picture Eric24  路  3Comments

abhishekpdubey picture abhishekpdubey  路  3Comments

epicfaace picture epicfaace  路  3Comments

sstarrAtmeta picture sstarrAtmeta  路  3Comments