maxDecimalPlaces<E> static method
Validates that the number has at most places decimal places.
NumberRules.maxDecimalPlaces(2, error: 'Max 2 decimal places')
Implementation
static Rule<double, E> maxDecimalPlaces<E>(int places, {required E error}) =>
PredicateRule(
predicate: (value) {
final str = value.toString();
final dotIndex = str.indexOf('.');
if (dotIndex == -1) return true;
return str.length - dotIndex - 1 <= places;
},
error: error,
);