authValidate.js 466 B

12345678910111213141516171819
  1. export const authValidate = values => {
  2. const { email, password } = values;
  3. const error = {};
  4. if(!email) {
  5. error.email = "Required"
  6. } else if (!/^[A-Z0-9._%+-]+@[A-Z0-9.]+\.[A-Z]{2,4}$/i.test(email)) {
  7. error.email = 'Invalid email address'
  8. }
  9. if(!password) {
  10. error.password = "Required"
  11. }else if(!/^[a-zA-Z0-9]+$/.test(password)) {
  12. error.password = "Invalid password"
  13. }
  14. return error;
  15. };