isValidPassword function
Password should have,
at least a upper case letter
at least a lower case letter
at least a digit
at least a special character @#$%^&+=
length of at least 4
no white space allowed
Implementation
bool isValidPassword(
String? inputString, {
bool isRequired = false,
}) {
bool isInputStringValid = false;
if (!isRequired && (inputString == null ? true : inputString.isEmpty)) {
isInputStringValid = true;
}
if (inputString != null && inputString.isNotEmpty) {
const pattern =
r'^(?=.*?[A-Z])(?=(.*[a-z]){1,})(?=(.*[\d]){1,})(?=(.*[\W]){1,})(?!.*\s).{8,}$';
final regExp = RegExp(pattern);
isInputStringValid = regExp.hasMatch(inputString);
}
return isInputStringValid;
}