1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-14 15:20:06 +02:00
copilot/spikes/form/redux-form/client/form/validate.js

28 lines
628 B
JavaScript
Raw Normal View History

const validator = require('validator');
const validate = values => {
console.log('validate values = ', values);
const errors = {};
if (!values.firstName) {
errors.firstName = 'Required';
}
if (!values.lastName) {
errors.lastName = 'Required';
}
if (!values.email) {
errors.email = 'Required';
} else if (!validator.isEmail(values.email)) {
errors.email = 'Invalid email address';
}
if (!values.sex) {
errors.sex = 'Required';
}
if (!values.favoriteColor) {
errors.favoriteColor = 'Required';
}
console.log('errors = ', errors);
return errors;
}
module.exports = validate;