password static method

FormFieldValidator<String> password({
  1. int minLength = 8,
  2. bool requireUppercase = false,
  3. bool requireSymbol = false,
  4. String? message,
})

Validates password strength.

Implementation

static FormFieldValidator<String> password({
  int minLength = 8,
  bool requireUppercase = false,
  bool requireSymbol = false,
  String? message,
}) =>
    (value) {
      if (value == null || value.isEmpty) return null;
      if (value.length < minLength) {
        return message ?? 'Password must be at least $minLength characters';
      }
      if (requireUppercase && !value.contains(RegExp(r'[A-Z]'))) {
        return 'Password must contain at least one uppercase letter';
      }
      if (requireSymbol &&
          !value.contains(RegExp(r'[!@#\$%^&*(),.?":{}|<>]'))) {
        return 'Password must contain at least one symbol';
      }
      return null;
    };