validatePassword method

String? validatePassword(
  1. String? value
)

Password matching expression. Password must be at least 4 characters, no more than 8 characters, and must include at least one upper case letter, one lower case letter, and one numeric digit.

Implementation

String? validatePassword(String ? value) {
  if (value==null || value.isEmpty) return "Please enter your password";
  if (!RegExp(r"^(?=.*[A-Za-z])(?=.*\d).{6,}$").hasMatch(value)) {
    return 'Password should be alphanumeric';
  }
  if (value.length <= 7) {
    return "Password should be more than 8 character";
  }
  if(value.length >25){
    return "Password should be less than 25 character";
  }
  // Pattern pattern =
  //     r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{6,}$';
  // RegExp regex =   RegExp(pattern);
  // if (!regex.hasMatch(value.trim())) {
  //   return "include one capital letter, number and symbol";
  // }
  return null;
}