rjsf-team / react-jsonschema-form

A React component for building Web forms from JSON Schema.
https://rjsf-team.github.io/react-jsonschema-form/
Apache License 2.0
14.35k stars 2.19k forks source link

How to skip automatic validation after `noValidate` was deprecated? #4379

Open ioanac95 opened 2 days ago

ioanac95 commented 2 days ago

Prerequisites

What theme are you using?

core

What is your question?

The noValidate prop on the Form component appears to have been deprecated in a recent release, prompting the omission of the validator to achieve the same goal in the future. However, for now the validator prop is required.

What is the recommended approach for skipping validation, for now?

Some background: I'm using rjsf to render a form whose definition is sent from a backend, and I'm using a mobx store to handle both change events, saving intermediate state (which involves a server request and validation of fields without taking into account required fields in the schema) and submission. Initially, I was relying on the inbuilt validation mechanisms for submission, and setting the extraErrors prop for the server errors or the custom validation happening on save. However, resetting the errors set from submit only happened on resubmission, and because of the use of Mobx with the form the liveValidate was causing problems (validating the whole form on page load when setting an empty formData prop). It seems like there's no recommended approach for resetting these errors without validating the whole form again, is that correct? To avoid these clashes and have more control over setting errors, I'm now using the extraErrors prop for submission as well and so want to skip the default validation mechanisms.

Appreciate the support!

heath-freenome commented 2 days ago

@ioanac95 when we remove the noValidate flag we will make the validator optional.