Last active
July 14, 2018 20:32
-
-
Save wwwhatley/7d04836d1b0cd754854502e9ae1c132f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
validate={values => { | |
let errors = {}; | |
// REGEX | |
let regex = !/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i; | |
// VALIDATION | |
if (!values.email) { | |
errors.email = "Email is required"; | |
} else if (regex.test(values.email)) { | |
errors.email = "Invalid email address"; | |
} | |
if (!values.password) { | |
errors.password = "A password is required"; | |
} else if (values.password.length < 6) { | |
errors.password = "Password must be 6 characters"; | |
} | |
return errors; | |
}} | |
onSubmit={values => { | |
console.log(values); | |
}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment