nonNegativeNumber static method
Validate non-negative number
Implementation
static String? nonNegativeNumber(String? value, {String? fieldName}) {
final numericError = numeric(value, fieldName: fieldName);
if (numericError != null) return numericError;
final numericValue = double.parse(value!);
if (numericValue < 0) {
return '${fieldName ?? 'This field'} cannot be negative';
}
return null;
}