Form can be submitted even with validation errors
See original GitHub issueHey 😃
Are you submitting a bug report or a feature request
Bug report
What is the current behavior
Even with validation errors, I am able to submit a non-valid form if not all fields are rendered.
What is the expected behavior
I expect that I will be not able to submit a non-valid form that has validation errors.
How to reproduce the issue
I took Synchronous Record-Level Validation example and slightly modified it - removed two fields and added console.log
with validation errors.
Here is a codesandbox demo - https://codesandbox.io/s/53xrn6v86p
Try to submit an empty form and you will have 3 validation errors. Now, fill in the only field in the form and you’ll still have 2 validation errors. Even though you have errors left, you will be able to submit the form.
Screen Shot
This bug also exists in redux-form and was mentioned in issues multiple times. 😢
Maybe it’ll be fixed in the final-form
(the title sounds awesome) 🎉
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:21 (13 by maintainers)
The
valid
/invalid
flags are currently based solely on registered fields.Having thought about this for 24 hours, I think @VladShcherbin might be right. Non-registered field errors should also affect
valid
/invalid
flags and halt submission.@erikras extra functionality + reduced bundle size 🙂 Maybe you have to reconsider your
You can add “If it reduces bundle size, it will have a bigger change of being implemented” 😂