range<E> static method

Rule<DateTime, E> range<E>(
  1. DateTime start,
  2. DateTime end, {
  3. required E error,
})

Validates that the date is within start and end (inclusive).

DateRules.range(startDate, endDate, error: 'Date out of range')

Implementation

static Rule<DateTime, E> range<E>(
  DateTime start,
  DateTime end, {
  required E error,
}) =>
    PredicateRule(
      predicate: (value) =>
          (value.isAfter(start) || value.isAtSameMomentAs(start)) &&
          (value.isBefore(end) || value.isAtSameMomentAs(end)),
      error: error,
    );