validatePattern static method

String? validatePattern(
  1. String value, {
  2. required String label,
  3. required String pattern,
  4. String? errorMessage,
})

Implementation

static String? validatePattern(
  String value, {
  required String label,
  required String pattern,
  String? errorMessage,
}) {
  if (value.trim().isEmpty) return emptyMessage;

  if (hasMatch(pattern: pattern, value: value)) return null;

  return errorMessage ?? '$enterValid $label';
}