isStrongPassword method

bool isStrongPassword(
  1. String? password
)

验证密码强度(至少8位,包含大小写字母、数字和特殊字符)

Implementation

bool isStrongPassword(String? password) {
  if (password == null || password.length < 8) return false;

  final hasUpper = hasMatch(password, r'[A-Z]');
  final hasLower = hasMatch(password, r'[a-z]');
  final hasDigits = hasMatch(password, r'\d');
  final hasSpecial = hasMatch(password, r'[!@#$%^&*(),.?":{}|<>]');

  return hasUpper && hasLower && hasDigits && hasSpecial;
}