matchesFn method

FieldValidator<String?, String?> matchesFn(
  1. ValueGetter<RegExp> regExp, [
  2. MessageCallBack<String>? message
])

check is the value matches regExp

Implementation

FieldValidator<String?, String?> matchesFn(ValueGetter<RegExp> regExp,
    [MessageCallBack<String>? message]) {
  return next((messages, value) {
    var rgEx = regExp();
    if (value != null && !rgEx.hasMatch(value)) {
      return message?.call(messages, value) ?? messages.regexp;
    }
    return null;
  });
}