Password validation in dart with RegExp
bool isPasswordCompliant(String password, [int minLength = 8]) {
if (password == null || password.length < minLength) {
return false;
}
bool hasUppercase = password.contains(RegExp(r'[A-Z]'));
if (hasUppercase) {
bool hasDigits = password.contains(RegExp(r'[0-9]'));
if (hasDigits) {
bool hasLowercase = password.contains(RegExp(r'[a-z]'));
if (hasLowercase) {
bool hasSpecialCharacters = password.contains(RegExp(r'[!@#$%^&*(),.?":{}|<>]'));
return hasSpecialCharacters;
}
}
}
return false;
}