react-schema-form
react-schema-form copied to clipboard
validation behaviour on blur
Is there a way I can change the validation behavior? It seems to affect the demo page too. If I load a form, I can immediately save it without actually firing any validation. I also want to validation errors to immediately load (the red ones) when I initialize it. Only after entering some data then removing it with backspace will show the "this field is required" error for example.
Additionally, and I think this is a more generic question with regards to react, but still related:
if I have
<mycontainer >
<SchemaForm />
<MySubmitButton />
</mycontainer>
How can I make the mysubmitbutton check the validity of the form prior to allowing the submit, or even bind the enablement status of the button to the validity status of the form?
thanks
These are all goog questions. The current released version should fire validation when the form is submitted. The demo is a little old. For the second question, do you have logic in your submit button? If not, you can use generated button. Otherwise, you csn call schema form api from you button.
I have the same situation. This is my submit callback
sendCredentials: function(e) {
e.preventDefault();
let result = utils.validateBySchema(this.state.schema, this.state.model);
if (result.error !== null) {
console.log(result);
}
},
It seems like a bug - if I submit form with incorrect fields, validation fires and I see this in console, but there are no indication at wrong fields in form
@alexey-kuznetsov From what you have describe it is a bug. I will try to reproduce and get it fixed. Thanks for your help.
@stevehu embedded validation doesn't prevent form from submitting. It is not normal.