Alex il y a 5 ans
Parent
commit
b0819b0eea
1 fichiers modifiés avec 19 ajouts et 0 suppressions
  1. 19 0
      src/utils/authValidate.js

+ 19 - 0
src/utils/authValidate.js

@@ -0,0 +1,19 @@
+export const authValidate =  values => {
+    const { email, password } = values;
+    const error = {};
+
+
+    if(!email) {
+        error.email = "Required"
+    } else if (!/^[A-Z0-9._%+-]+@[A-Z0-9.]+\.[A-Z]{2,4}$/i.test(email)) {
+        error.email = 'Invalid email address'
+    }
+
+    if(!password) {
+        error.password = "Required"
+    }else if(!/^[a-zA-Z0-9]+$/.test(password)) {
+        error.password = "Invalid password"
+    }
+
+    return error;
+};