isMoney function
return an error message if value does not pass the validation validation requires val: not equal null and length must be more or equal to 10 characters
Implementation
// ignore: missing_return
String? isMoney(String value, num min, num max, {String symbol = "NGN"}) {
try {
if (value.isEmpty) return "must not be less than ${min.toMoney} $symbol";
final val =
int.parse(value.substring(0, value.length - 3).replaceAll(",", ""));
if (val < min) return "must not be less than ${min.toMoney} $symbol";
if (val > max) return "must not be more than a ${max.toMoney} $symbol";
return null;
} catch (e) {
debugPrint(e.toString());
}
return "";
}