fix(18-07): money accepts trailing zeros beyond the field scale
A scale-2 money field over a four-decimal column (the documented fee example) was served "12.5000" and answered money.too_precise when the untouched value was saved back. Trailing zeros carry no precision, so the server check and the SPA parser count only significant fraction digits; the value still reaches the column unchanged, never rounded or truncated. - cabana validateMoneyValue and admin parseMoneyInput trim trailing zeros before the scale comparison - forms docs and cabana README name the rule; embedded dist rebuilt - MoneyField spec asserts 12.5000 at scale 2 is accepted, 12.5010 refused
This commit is contained in:
@@ -65,6 +65,9 @@ describe('money helpers', () => {
|
||||
expect(parseMoneyInput('', 4)).toEqual({ value: null, error: null })
|
||||
expect(parseMoneyInput(' ', 4)).toEqual({ value: null, error: null })
|
||||
expect(parseMoneyInput('12.34567', 4)).toEqual({ value: null, error: 'too_precise' })
|
||||
// Trailing zeros beyond the scale carry no precision: kept, accepted.
|
||||
expect(parseMoneyInput('12.5000', 2)).toEqual({ value: '12.5000', error: null })
|
||||
expect(parseMoneyInput('12.5010', 2)).toEqual({ value: null, error: 'too_precise' })
|
||||
expect(parseMoneyInput('1.234,56', 4)).toEqual({ value: null, error: 'invalid' })
|
||||
expect(parseMoneyInput('12a', 4)).toEqual({ value: null, error: 'invalid' })
|
||||
expect(parseMoneyInput('1e3', 4)).toEqual({ value: null, error: 'invalid' })
|
||||
|
||||
Reference in New Issue
Block a user