isPositiveDecimalRate function
Whether rate is a strictly-positive plain decimal string — the only kind
of conversion rate that can be applied safely.
Returns false for a non-decimal, signed, empty, or whitespace string
(anything foldEntryUsd would reject with a FormatException) and also for
an exactly-zero rate ("0", "0.0", …): a zero rate converts every amount
to zero, which would silently under-count rather than convert. Callers use
this both to reject a bad rate at the boundary (before it is stored) and to
fail closed at conversion time if an unvalidated rate is ever encountered.
Implementation
bool isPositiveDecimalRate(String rate) {
final BigInt numerator;
try {
numerator = _parseDecimalRate(rate).num;
} on FormatException {
return false;
}
return numerator > BigInt.zero;
}