maxValue static method

String? maxValue(
  1. String? value,
  2. num max, {
  3. String? message,
})

Validates that a numeric value is less than a maximum

Example:

Validators.maxValue('10', 20);

Implementation

static String? maxValue(String? value, num max, {String? message}) {
  if (value == null || value.isEmpty) return null;
  final numValue = num.tryParse(value);
  if (numValue == null || numValue > max) {
    return message ?? 'Value must be at most $max';
  }
  return null;
}