react-inform
react-inform copied to clipboard
Getting list of errors explicitly
Currently, react-inform has forceValidate()
which exposes snapshot of errors to the props. We found ourselves in a situation when we need to get full list of current errors synchronously.
Do you think a method which returns a copy (?) of form.state.errors
could be introduced?
@indeyets In your use case, do you want errors that are currently not shown to the UI because the inputs haven't been touched
yet?
@theadam yup. strictly speaking we want to handle the case of incomplete initial data and, additionally, to have a safeguard against bogus initial data
we could resolve this via pre-processing, but in this case it looks like it's easier to do this at the point of form submission
@indeyets Have you taken a look at the included form submit buttons.
Not sure if this is exactly what you want, but: https://github.com/theadam/react-inform/blob/master/src/feedbackFormSubmit.js
This will show any errors when a user tries to submit the form. There is also a callback when the form is invalid. Let me know if this is close to what you want.