react-bootstrap-validation
react-bootstrap-validation copied to clipboard
Dependent Field Validation Not Triggered
As state in the docs dependent field validation can be achieved using validate={(val, context) => val === context.password}.
However when using this approach or even validateAll, if a user was to fix up the input by changing the password field instead of the password-confirm field the password-confirm will still present an error since no event has triggered on the password-confirm i.e. onChange, onBlur or onFocus.
In the case of the validateAll it would be good if all errors were cleared since they will be re-raised if they still exist as per the schema check.
For validate on a field it would be useful to have an optional list of dependent fields which the library would trigger the field validation on any time this field triggers. Obviously there are cyclic issues here which would be good to detect and stop. i.e. each dependent field will only trigger is validation once.
In my cases I'm using validateAll and so as a workaround I extended the Form component and override the _validateAll function
import R from 'ramda'
_validateAll(context) { R.forEach(x => super._setError(x,false), R.keys(context)) return super._validateAll(context) }
Yeah, I thought this may raise an issue... I'll think about it.