`getErrorMessages` should return empty array when there are no errors
This commit is contained in:
parent
89759fefde
commit
357f4adf71
|
|
@ -140,10 +140,11 @@ module.exports = {
|
|||
return this.state._value !== '';
|
||||
},
|
||||
getErrorMessage: function () {
|
||||
return this.getErrorMessages() && this.getErrorMessages()[0];
|
||||
var messages = this.getErrorMessages();
|
||||
return messages.length ? messages[0] : null;
|
||||
},
|
||||
getErrorMessages: function () {
|
||||
return !this.isValid() || this.showRequired() ? (this.state._externalError || this.state._validationError) : null;
|
||||
return !this.isValid() || this.showRequired() ? (this.state._externalError || this.state._validationError || []) : [];
|
||||
},
|
||||
isFormDisabled: function () {
|
||||
return this.context.formsy.isFormDisabled();
|
||||
|
|
|
|||
|
|
@ -317,7 +317,8 @@ Formsy.Form = React.createClass({
|
|||
}
|
||||
|
||||
if (isRequired) {
|
||||
return [validationErrors[requiredResults.success[0]]] || null;
|
||||
var error = validationErrors[requiredResults.success[0]];
|
||||
return error ? [error] : null;
|
||||
}
|
||||
|
||||
if (validationResults.failed.length) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue