moderatePassword static method

bool moderatePassword(
  1. String password
)

Validates whether the given password is moderate according to a predefined pattern.

The password parameter should be a string.

The pattern requires at least one digit, one uppercase letter, one lowercase letter, and the total length of at least 8 characters.

Returns true if the password is moderate, false otherwise.

Implementation

static bool moderatePassword(String password) {
  String pattern =
      r'(?=(.*[0-9]))((?=.*[A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z]))^.{8,}$';
  RegExp regExp = RegExp(pattern);
  return regExp.hasMatch(password);
}