add initial form validation
This commit is contained in:
parent
baa2c121f0
commit
ab193a0271
2 changed files with 23 additions and 0 deletions
|
@ -27,6 +27,12 @@ function mapDispatchToProps(dispatch) {
|
|||
|
||||
function validate(formProps) {
|
||||
const errors = {};
|
||||
if (!formProps.email) {
|
||||
errors.email = 'Please enter a email';
|
||||
}
|
||||
if (!formProps.password) {
|
||||
errors.password = 'Please enter a password';
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,23 @@ function mapDispatchToProps(dispatch) {
|
|||
|
||||
function validate(formProps) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue