Skip to content

Instantly share code, notes, and snippets.

@catalinsgh
Created June 29, 2020 19:22
Show Gist options
  • Save catalinsgh/c8489c2caf83582633847a0f0d71539a to your computer and use it in GitHub Desktop.
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
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