regExp method

FormFieldValidator<String> regExp (
  1. RegExp pattern,
  2. [String errorMessage]
)

Implementation

static FormFieldValidator<String> regExp(RegExp pattern,
    [String errorMessage]) {
  return (value) {
    if (value.isEmpty) return null;

    if (pattern.hasMatch(value))
      return null;
    else
      return errorMessage ?? "Do not match the required pattern rules";
  };
}