add initial form validation

This commit is contained in:
catarak 2016-06-24 14:22:32 -04:00
parent baa2c121f0
commit ab193a0271
2 changed files with 23 additions and 0 deletions

View file

@ -27,6 +27,12 @@ function mapDispatchToProps(dispatch) {
function validate(formProps) { function validate(formProps) {
const errors = {}; const errors = {};
if (!formProps.email) {
errors.email = 'Please enter a email';
}
if (!formProps.password) {
errors.password = 'Please enter a password';
}
return errors; return errors;
} }

View file

@ -27,6 +27,23 @@ function mapDispatchToProps(dispatch) {
function validate(formProps) { function validate(formProps) {
const errors = {}; const errors = {};
if (!formProps.username) {
errors.username = 'Please enter a username';
}
if (!formProps.email) {
errors.email = 'Please enter an email';
}
if (!formProps.password) {
errors.password = 'Please enter a password';
}
if (!formProps.confirmPassword) {
errors.confirmPassword = 'Please enter a password confirmation';
}
if (formProps.password !== formProps.passwordConfirm) {
errors.password = 'Passwords must match';
}
return errors; return errors;
} }