Skip to content

fix(validation): reject malformed numbers in debug-form amount rules - #480

Open
devorun wants to merge 1 commit into
circlefin:masterfrom
devorun:fix/debug-form-number-validation
Open

devorun wants to merge 1 commit into
circlefin:masterfrom
devorun:fix/debug-form-number-validation

Conversation

@devorun

@devorun devorun commented Sep 6, 2026

Copy link
Copy Markdown

Summary

Ten debug pages inline their numeric input rule as:

v === '' || !isNaN(parseInt(v)) || 'Please enter valid number'

parseInt parses a leading numeric prefix and ignores the rest, so parseInt("12abc") === 12 — meaning "12abc" (and "1.5x", "0x10", etc.) passes the rule. A field that passes is then read with parseFloat, which coerces the malformed value to a different number than the user typed.

Fix

Match the whole string against an optionally-signed integer/decimal number instead:

v === '' || /^-?\d+(\.\d+)?$/.test(v) || 'Please enter valid number'

One-line change per page; signed and decimal values keep working, empty stays valid, and trailing garbage / hex / scientific-notation strings are now rejected.

Pages fixed: businessAccount/bankAccounts/{create,fetch}, businessAccount/transfers/fetch, paymentIntents/fetch, payments/fetch, payouts/fetch, settlements/fetch, stablefx/quote, trades/flow/index, trades/quote.

Notes

These are divergent inline copies of the shared isNumber rule in helpers/validation.ts (which other debug pages import, and which #470 hardens with the same regex). This applies the same correctness fix to the pages that bypass the shared helper. eslint is clean on the changed files.

Ten debug pages inline the numeric input rule as `!isNaN(parseInt(v))`.
parseInt parses a leading numeric prefix and ignores the rest, so
"12abc" passed validation; a downstream parseFloat would then move a
different value than the user typed.

Match the whole string against an (optionally signed) integer/decimal
number instead. This mirrors the fix to the shared isNumber rule in
helpers/validation.ts (circlefin#470); these pages carry divergent inline copies
that bypass it.
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.

1 participant