customRegexValidator static method

String? customRegexValidator(
  1. String? value,
  2. String pattern,
  3. String errorMessage
)

Implementation

static String? customRegexValidator(String? value, String pattern, String errorMessage) {
  final regex = RegExp(pattern);
  if (!regex.hasMatch(value ?? '')) {
    return errorMessage;
  }
  return null;
}