constrained method
PostgreSQL-style column coercion: round ties away from zero, then check precision. Expression result codecs do not inherit column constraints.
Implementation
Decimal constrained(int precision, int scale) {
validateDigits(precision, scale);
final result = rounded(scale, rounding: DecimalRounding.halfAwayFromZero);
if (!result.fits(precision, scale)) {
throw RangeError('Decimal does not fit NUMERIC($precision, $scale).');
}
return result;
}