Skip to content

fix(money): reject fractional-cent numbers - #54

Merged
ralyodio merged 1 commit into
moshcoder:masterfrom
aiirvizionz:clientkit/strict-numeric-money-cents
Jul 30, 2026
Merged

fix(money): reject fractional-cent numbers#54
ralyodio merged 1 commit into
moshcoder:masterfrom
aiirvizionz:clientkit/strict-numeric-money-cents

Conversation

@aiirvizionz

Copy link
Copy Markdown
Contributor

Summary

  • make numeric money input follow the same cent-precision rule as string input
  • reject JS numbers that represent more than two decimal places or round below one cent
  • add regression coverage for 1.234 and 0.004 numeric inputs

Validation

  • node --test tests\*.mjs passed 22 tests

@ralyodio
ralyodio merged commit cd44122 into moshcoder:master Jul 30, 2026
2 checks passed
ralyodio pushed a commit that referenced this pull request Jul 31, 2026
The numeric path in setupAmountUsd silently rounded values like 1.234
to 1.23. The string path already enforces cent-precision via regex;
make the numeric path reject fractional cents too so both inputs follow
the same rule.

Fixes #54

Co-authored-by: qwenbona <qwenbona@users.noreply.github.com>
ralyodio added a commit that referenced this pull request Jul 31, 2026
PR #59 made the numeric path of setupAmountUsd reject values finer than
a cent, but left the assertion that 2.345 rounds to 2.35 — the exact
behavior it removed. That assertion has failed on master ever since, so
every PR opened since #59 shows a red test check.

Assert the numeric path on a value it actually accepts, and add the
regression coverage issue #54 asked for (1.234 and 0.004) that #59
described but never landed.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants