Created
June 29, 2020 19:22
-
-
Save catalinsgh/c8489c2caf83582633847a0f0d71539a to your computer and use it in GitHub Desktop.
Class used to validate that a string matches a certain set of criteria
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
class PasswordValidator { | |
fun isValid(password: String) = PATTERN.matcher(password).matches() | |
private companion object { | |
val PATTERN: Pattern = Pattern.compile("^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@\$%^&*-]).{8,}\$") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment