validateInteger function
Implementation
String? validateInteger(
String? value, {
required int min,
int? max,
}) {
if (value == null || value.isEmpty) return 'Cannot be empty';
int? intValue = int.tryParse(value);
if (intValue == null) {
return 'Must be a valid number';
}
if (intValue < min) {
return 'Must be at least $min';
}
if (max != null && intValue > max) {
return 'Must be at most $max';
}
return null;
}