isPasswordValid static method

String? isPasswordValid(
  1. String password, {
  2. String? message,
  3. String? passwordLFormatMessage,
  4. int? passwordLength = 8,
})

Implementation

static String? isPasswordValid(String password,
    {String? message,String? passwordLFormatMessage,int? passwordLength=8}) {
  if(password.isEmpty){
    return passwordValidationMessage;
  }else if (password.length < passwordLength!) {
    return message??passwordLengthValidationMessage;
  }else if (!RegExp(
          r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{8,}$')
      .hasMatch(password)) {
    return passwordLFormatMessage??"Password should contain at least one uppercase letter, one lowercase letter, one number and one special character";
  }
  return null;
}