beWithin method

void beWithin(
  1. num min,
  2. num max, [
  3. String? errorMessage
])

Instructs NumberMust to make sure the given number is within the range min and max, both end inclusive.

Implementation

void beWithin(num min, num max, [String? errorMessage]) {
  _validators.add((value) {
    if (value == null || value < min || value > max)
      return errorMessage ?? 'Number is not within $min and $max';
    return '';
  });
}