Clarify finding first non-null field error
This commit is contained in:
parent
8e32798f45
commit
4b29d5e228
1 changed files with 5 additions and 2 deletions
|
@ -289,8 +289,11 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onFormValidationChange: function(fieldErrors) {
|
onFormValidationChange: function(fieldErrors) {
|
||||||
// Find the first error and show that.
|
// `fieldErrors` is an object mapping field IDs to error codes when there is an
|
||||||
const errCode = Object.values(fieldErrors).find(value => value);
|
// error or `null` for no error, so the values array will be something like:
|
||||||
|
// `[ null, "RegistrationForm.ERR_PASSWORD_MISSING", null]`
|
||||||
|
// Find the first non-null error code and show that.
|
||||||
|
const errCode = Object.values(fieldErrors).find(value => !!value);
|
||||||
if (!errCode) {
|
if (!errCode) {
|
||||||
this.setState({
|
this.setState({
|
||||||
errorText: null,
|
errorText: null,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue