checkStrength static method
PasswordStrength
checkStrength(
- String password, {
- EnforcingPattern enforcingPattern = const EnforcingPattern(),
Returns a value of type PasswordStrength, which is how secure is the given password, according to the provided EnforcingPattern.
Implementation
static PasswordStrength checkStrength(
String password, {
EnforcingPattern enforcingPattern = const EnforcingPattern(),
}) {
PasswordStrength strength;
if (RegExp(enforcingPattern.tightPattern).hasMatch(password)) {
strength = PasswordStrength.STRONG;
} else if (RegExp(enforcingPattern.mediumPattern).hasMatch(password)) {
strength = PasswordStrength.GOOD;
} else if (RegExp(enforcingPattern.loosePattern).hasMatch(password)) {
strength = PasswordStrength.WEAK;
} else {
strength = PasswordStrength.VERY_WEAK;
}
return strength;
}