integer static method
Validates that the input is an integer.
Implementation
static String? Function(String) integer({
String message = 'Please enter a valid integer.',
int? min,
int? max,
}) {
return (value) {
if (value.trim().isEmpty) return null;
final num = int.tryParse(value);
if (num == null) return message;
if (min != null && num < min) return 'Value must be at least $min.';
if (max != null && num > max) return 'Value must be at most $max.';
return null;
};
}