maxYear static method
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));
};