no need to have blank 'errors' property in the states. validation plugin now handles that
This commit is contained in:
@@ -11,7 +11,7 @@ var RibicaValidationMixin = {
|
||||
_validate: function(prop, value) {
|
||||
if(this.validations && this.validations[prop]) {
|
||||
var cb = function(err, revalidateFields) {
|
||||
var errors = this.state.errors;
|
||||
var errors = this.state.errors || {};
|
||||
if (err !== undefined) {
|
||||
if(err.length > 0) {
|
||||
errors[prop] = err;
|
||||
@@ -44,7 +44,8 @@ var RibicaValidationMixin = {
|
||||
|
||||
},
|
||||
getValidationMessages:function(prop) {
|
||||
return (this.state.errors[prop] || []);
|
||||
var errors = this.state.errors || {};
|
||||
return (errors[prop] || []);
|
||||
},
|
||||
validateField: function(field) {
|
||||
this._validate(field, this.state[field]);
|
||||
@@ -58,7 +59,8 @@ var RibicaValidationMixin = {
|
||||
return this.isValid();
|
||||
},
|
||||
isValid: function() {
|
||||
return Object.keys(this.state.errors).length === 0;
|
||||
var errors = this.state.errors || {};
|
||||
return Object.keys(errors).length === 0;
|
||||
},
|
||||
componentDidMount : function(){
|
||||
if (this.validations) {
|
||||
|
||||
Reference in New Issue
Block a user