Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const strongPassword = new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})");
- function likeGithubStyle(password) {
- const hasLetters = new RegExp("^(?=.*[A-Za-z])")
- const hasNumber = new RegExp("^(?=.*[0-9])")
- const hasSize = new RegExp("^(?=.{8,})")
- if (!hasLetters.test(password)) return {error: true, message: 'Missing letters'}
- if (!hasNumber.test(password)) return {error: true, message: 'Missing numbers'}
- if (!hasSize.test(password)) return {error: true, message: 'Missing size'}
- return {error: false, message: 'OK'}
- }
- function passwordIsStrong(password) {
- const strongPassword = new RegExp("^(?=.*[a-zA-Z])(?=.*[0-9])(?=.{8,})");
- return strongPassword.test(password)
- }
- const hasLowercase = new RegExp("^(?=.*[a-z])")
- const hasUppercase = new RegExp("^(?=.*[A-Z])")
- const hasNumber = new RegExp("^(?=.*[0-9])")
- const hasSpecialchar = new RegExp("^(?=.*[!@#\$%\^&\*])")
- const hasSize = new RegExp("^(?=.{8,})")
- const password = 'bananaMaster123'
- const result = strongPassword.test(password)
- const hasL = hasLowercase.test(password)
- const hasU = hasUppercase.test(password)
- const hasN = hasNumber.test(password)
- const hasSC = hasSpecialchar.test(password)
- const hasSI = hasSize.test(password)
- console.log('Final result: ' + result)
- console.log('lowercase: ' + hasL)
- console.log('uppercase: ' + hasU)
- console.log('number: ' + hasN)
- console.log('special char: ' + hasSC)
- console.log('size: ' + hasSI)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement