no need to have blank 'errors' property in the states. validation plugin now handles that
This commit is contained in:
@@ -58,6 +58,8 @@ var UserActions = {
|
||||
actionType: UserConstants.USER_LOGIN
|
||||
});
|
||||
|
||||
|
||||
|
||||
superagent.post(globals.ApiUrl + '/user/login')
|
||||
.withCredentials()
|
||||
.send(loginDetails)
|
||||
|
||||
@@ -31,7 +31,6 @@ var Login = React.createClass({
|
||||
return {
|
||||
email: '',
|
||||
password: '',
|
||||
errors: {},
|
||||
login: UserStore.getLoginState()
|
||||
};
|
||||
},
|
||||
|
||||
@@ -18,7 +18,6 @@ var Register = React.createClass({
|
||||
email: '',
|
||||
password: '',
|
||||
passwordConfirmation: '',
|
||||
errors: {},
|
||||
registration: UserStore.getRegistrationState()
|
||||
};
|
||||
},
|
||||
|
||||
@@ -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