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
|
actionType: UserConstants.USER_LOGIN
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
superagent.post(globals.ApiUrl + '/user/login')
|
superagent.post(globals.ApiUrl + '/user/login')
|
||||||
.withCredentials()
|
.withCredentials()
|
||||||
.send(loginDetails)
|
.send(loginDetails)
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ var Login = React.createClass({
|
|||||||
return {
|
return {
|
||||||
email: '',
|
email: '',
|
||||||
password: '',
|
password: '',
|
||||||
errors: {},
|
|
||||||
login: UserStore.getLoginState()
|
login: UserStore.getLoginState()
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ var Register = React.createClass({
|
|||||||
email: '',
|
email: '',
|
||||||
password: '',
|
password: '',
|
||||||
passwordConfirmation: '',
|
passwordConfirmation: '',
|
||||||
errors: {},
|
|
||||||
registration: UserStore.getRegistrationState()
|
registration: UserStore.getRegistrationState()
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ var RibicaValidationMixin = {
|
|||||||
_validate: function(prop, value) {
|
_validate: function(prop, value) {
|
||||||
if(this.validations && this.validations[prop]) {
|
if(this.validations && this.validations[prop]) {
|
||||||
var cb = function(err, revalidateFields) {
|
var cb = function(err, revalidateFields) {
|
||||||
var errors = this.state.errors;
|
var errors = this.state.errors || {};
|
||||||
if (err !== undefined) {
|
if (err !== undefined) {
|
||||||
if(err.length > 0) {
|
if(err.length > 0) {
|
||||||
errors[prop] = err;
|
errors[prop] = err;
|
||||||
@@ -44,7 +44,8 @@ var RibicaValidationMixin = {
|
|||||||
|
|
||||||
},
|
},
|
||||||
getValidationMessages:function(prop) {
|
getValidationMessages:function(prop) {
|
||||||
return (this.state.errors[prop] || []);
|
var errors = this.state.errors || {};
|
||||||
|
return (errors[prop] || []);
|
||||||
},
|
},
|
||||||
validateField: function(field) {
|
validateField: function(field) {
|
||||||
this._validate(field, this.state[field]);
|
this._validate(field, this.state[field]);
|
||||||
@@ -58,7 +59,8 @@ var RibicaValidationMixin = {
|
|||||||
return this.isValid();
|
return this.isValid();
|
||||||
},
|
},
|
||||||
isValid: function() {
|
isValid: function() {
|
||||||
return Object.keys(this.state.errors).length === 0;
|
var errors = this.state.errors || {};
|
||||||
|
return Object.keys(errors).length === 0;
|
||||||
},
|
},
|
||||||
componentDidMount : function(){
|
componentDidMount : function(){
|
||||||
if (this.validations) {
|
if (this.validations) {
|
||||||
|
|||||||
Reference in New Issue
Block a user