isValidPassword property
bool
get
isValidPassword
Checks if the string is a strong password.
Password must:
- Be at least 8 characters long
- Contain at least one uppercase letter
- Contain at least one lowercase letter
- Contain at least one digit
- Contain at least one special character (
!@#><*~)
Example:
'Str0ng!Pass'.isValidPassword; // true
Implementation
bool get isValidPassword {
final passwordRegExp = RegExp(
r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#><*~]).{8,}$',
);
return passwordRegExp.hasMatch(this);
}