isDateInPast function
DateTime must be in the past.
Implementation
IValidator isDateInPast({bool allowNow = true, String? message}) {
final now = DateTime.now();
return _datePredicate(
defaultMessage: 'a DateTime in the past${allowNow ? ' or now' : ''}',
test: (v) => allowNow ? !v.isAfter(now) : v.isBefore(now),
code: ExpectationCodes.valueDateNotPast,
dataBuilder: () => {'now': now.toIso8601String(), 'allowNow': allowNow},
message: message,
);
}