range static method

String Function(double?) range(
  1. double min,
  2. double max, [
  3. String? message
])

Creates a validation rule that enforces a numeric range.

Returns an error message if the value is outside the range min, max. If message is not provided, uses a default message.

Example:

Validations.range(1, 10, 'Value must be between 1 and 10')

Implementation

static String Function(double?) range(double min, double max, [String? message]) {
  return (double? value) {
    if (value == null) return '';
    if (value < min || value > max) {
      return message ?? 'Value must be between $min and $max';
    }
    return '';
  };
}