maxYear static method

Validator<DateTime> maxYear(
  1. int max, {
  2. String? error,
})

Implementation

static Validator<DateTime> maxYear(int max, {String? error}) => (
      value,
      context,
    ) {
      final DateTimeResource? datetimeResource =
          context.resources.getOrCreate(
        value.toString(),
        () => DateTimeResource(value),
      );
      if (datetimeResource == null) {
        return (false, context.warnings.dateTimeResourceNotFound());
      }
      if (datetimeResource.isMaxYear(max)) return (true, null);
      return (false, error ?? context.errors.stringDateErrors.maxYear(max));
    };