past function

String past (
  1. DateTime fieldValue,
  2. {String message}
)

Validates that fieldValue (DateTime) is in the past.

Returns null if fieldValue < DateTime.now() else an error message

Implementation

String past(
  DateTime fieldValue, {
  String message,
}) {
  if ((fieldValue == null) || (fieldValue.isBefore(DateTime.now()))) {
    return null;
  }
  return message ?? 'The value must be in the past';
}