matches static method

String? matches(
  1. String? checkValue,
  2. String pattern, {
  3. String? errorMessage,
})

Checks if checkValue can be matched by the regular expression pattern

If checkValue is null or is not matched by the RegEx pattern the errorMessage will be returned if provided, otherwise the default error. Otherwise null is returned

Implementation

static String? matches(String? checkValue, String pattern,
    {String? errorMessage}) {
  return ((checkValue == null) || !RegExp(pattern).hasMatch(checkValue))
      ? (errorMessage ?? "Field fails validation")
      : null;
}