Created
June 26, 2020 23:07
-
-
Save tektuitive/1bdbc425a27946f72b10d9e3fb083da5 to your computer and use it in GitHub Desktop.
React Native and AWS Amplify Tutorial Docs.
This file contains 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
export function validateEmail(email) { | |
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) { | |
return 'Enter a valid email address!'; | |
} else return null; | |
} | |
export function validatePassword(password) { | |
if ( | |
!/(?=(.*[0-9]))((?=.*[A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z]))^.{8,}$/i.test( | |
password, | |
) | |
) { | |
return 'Password should have 1 lowercase letter, 1 uppercase letter, 1 number, and be at least 8 characters long'; | |
} else return null; | |
} | |
export function validateUsername(username) { | |
if (!/^[a-z0-9_-]{3,16}$/i.test(username)) { | |
return 'Enter a user name 3 to 16 characters long'; | |
} else return null; | |
} | |
export function validateCode(code) { | |
if (!code) { | |
return 'Enter a valid codde'; | |
} else return null; | |
} |
Hello !
Really good lessons, waiting for others soon.
Thank you for this file too, appreciate the way you teach and share your knowledge.
Thanks for the code, this helps me a lot
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're welcome!