passwordValidator static method
- String? password
Implementation
static String? passwordValidator(String? password) {
if (password == null) return "Password can't be empty";
String patttern =
r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~?.-]).{8,}$';
RegExp regExp = RegExp(patttern);
if (password.isEmpty) {
return "Password can't be empty";
} else if (!regExp.hasMatch(password)) {
return 'Please enter a strong password';
}
return null;
}