innerValidate method

  1. @override
bool innerValidate(
  1. String? value
)
override

Returns true or false depending on the validation process. This method is then used by the ValidatorWithStaticError.validate method to return a static error if the result is false.

Implementation

@override
bool innerValidate(String? value) {
  final String regex;

  switch (mode) {
    case HexColorValidatorMode.both:
      regex = hexRegexWithBoth;
      break;
    case HexColorValidatorMode.withHashtag:
      regex = hexRegexWithHashtag;
      break;
    case HexColorValidatorMode.withoutHashtag:
      regex = hexRegexWithoutHashtag;
      break;
  }

  return value == null || RegExp(regex).hasMatch(value);
}