Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow validateOnSubmit #414

Open
daniel-candis opened this issue Apr 27, 2021 · 0 comments
Open

Allow validateOnSubmit #414

daniel-candis opened this issue Apr 27, 2021 · 0 comments

Comments

@daniel-candis
Copy link

Are you submitting a bug report or a feature request?

This is a feature request and I'm willing to provide a PR.

What is the current behavior?

When submitting a form, e. g. by writing into an input field and triggering enter, validation is not triggered. With validateOnBlur, this means that the field is never validated before submission.
Submission is blocked, though, if there are already errors in the form state. This means that when I have a form with errors, fix the errors and submit by pressing enter, then the submission will fail as validation did not run again.
This cannot be fixed outside the library, as the onSubmit and beforeSubmit hooks would only get called after hasSyncErrors already cancelled the execution.

What is the expected behavior?

Introduce a config flag validateOnSubmit that, if set, runs validation instead of calling hasSyncErrors in submit.

Sandbox Link

https://codesandbox.io/s/react-final-form-simple-example-forked-pgdml?file=/index.js

What's your environment?

Tested with react-final-form 6.5.2 and final-form 4.20.1.

Other information

Happy to contribute a PR if this feature is of interest.

Other related issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant