Skip to content

Instantly share code, notes, and snippets.

@mayowDev
Created December 2, 2020 07:52
Show Gist options
  • Save mayowDev/95270b2a697fa03889a1ae74539fa35d to your computer and use it in GitHub Desktop.
Save mayowDev/95270b2a697fa03889a1ae74539fa35d to your computer and use it in GitHub Desktop.
> Your password must be at least 8 characters long and include at least one number and one of the following symbols !@#$%^&()*
const isEmailValid = (mail) => {
if (mail) {
return /^\S+@\S+\.\S+$/.test(mail) === true
}
return true
}
const isPasswordValid = (pass) => {
if (pass) {
return pass.length > 7 && /^(?=.*\d)(?=.*[a-z])(?=.*[!@#$%^&()*])(?=.*[a-z]).{8,}$/i.test(pass) === true
}
return true
}
const checkPassword = (password) => {
if (password.length >= 1) {
const isValid = isPasswordValid(password)
console.log('isValid = ', isValid, password)
setPasswordValid(isValid)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment