Created
May 31, 2020 23:16
-
-
Save aronhoyer/b626d252784612777aa90a5b09d3b442 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
function passwordIsValid(password) { | |
if (password.length < 8 || password.length > 255) return false | |
const upper = [] | |
const lower = [] | |
const num = [] | |
const special = [] | |
password.split("").forEach(c => { | |
if (upper.length === 0 && c.match(/[A-Z]/)) upper.push(c) | |
if (lower.length === 0 && c.match(/[a-z]/)) lower.push(c) | |
if (num.length === 0 && c.match(/[0-9]/)) num.push(c) | |
if (special.length === 0 && c.match(/[@_-"!?+`´#$%&/()^¨*><,.;:]/)) special.push(c) | |
}) | |
return !!upper.length && !!lower.length && !!num.length && !!special.length | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment