pattern static method
Validates that the value matches a pattern
Example:
Validators.pattern(value, RegExp(r'^[A-Z]+$'));
Implementation
static String? pattern(String? value, RegExp pattern, {String? message}) {
if (value == null || value.isEmpty) return null;
if (!pattern.hasMatch(value)) {
return message ?? 'Invalid format';
}
return null;
}