lengthRange<T, E> static method

Rule<Iterable<T>, E> lengthRange<T, E>(
  1. int min,
  2. int max, {
  3. required E error,
})

Validates that the collection length is within min and max (inclusive).

CollectionRules.lengthRange(1, 5, error: 'Must have 1-5 items')

Implementation

static Rule<Iterable<T>, E> lengthRange<T, E>(
  int min,
  int max, {
  required E error,
}) =>
    PredicateRule(
      predicate: (value) => value.length >= min && value.length <= max,
      error: error,
    );