after static method
Implementation
static Validator<String> after(String date, {String? error}) => (
value,
context,
) {
final StringDateResource? stringDate = context.resources.tryGet(
'stringDateResource',
);
final String? format = context.resources.tryGet('format');
if (stringDate == null || format == null) {
return (false, context.warnings.resourcesNotFound());
}
final datetime = stringDate.parser.tryGetDateTime(date, format);
if (datetime == null) {
return (false, context.warnings.cantParseDateTime());
}
final DateTimeResource? datetimeResource = context.resources.tryGet(
'datetimeResource',
);
if (datetimeResource == null) {
return (false, context.warnings.dateTimeResourceNotFound());
}
if (datetimeResource.isAfter(datetime)) return (true, null);
return (false, error ?? context.errors.stringDateErrors.after(format));
};