Skip to content

Instantly share code, notes, and snippets.

@tektuitive
Created June 26, 2020 23:07
Show Gist options
  • Save tektuitive/1bdbc425a27946f72b10d9e3fb083da5 to your computer and use it in GitHub Desktop.
Save tektuitive/1bdbc425a27946f72b10d9e3fb083da5 to your computer and use it in GitHub Desktop.
React Native and AWS Amplify Tutorial Docs.
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;
}
@tektuitive
Copy link
Author

You're welcome!

@viateck
Copy link

viateck commented Jan 6, 2021

Hello !
Really good lessons, waiting for others soon.
Thank you for this file too, appreciate the way you teach and share your knowledge.

@nhanvo1297
Copy link

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