password static method
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;
};