Skip to content

fix(isNumeric): reject unknown decimal locales - #2926

Open
FanWu-ai wants to merge 1 commit into
validatorjs:masterfrom
FanWu-ai:fix/isnumeric-locale-validation-oct11
Open

FanWu-ai wants to merge 1 commit into
validatorjs:masterfrom
FanWu-ai:fix/isnumeric-locale-validation-oct11

Conversation

@FanWu-ai

Copy link
Copy Markdown

isNumeric currently builds a character class containing undefined when given a locale absent from the decimal-separator table. For example, isNumeric('12d34', { locale: 'de-CH' }) and isNumeric('n1', { locale: 'de-CH' }) both return true, while ordinary 3.5 returns false.

Reject unknown locale options, including inherited object-property names, before building that expression, following isDecimal, which reads the same separator table and already throws Invalid locale 'de-CH'. This does not add support for de-CH. The no_symbols path continues to ignore the locale because it does not use a decimal separator. The README documents the error behavior.

Validation (Node.js 24.19.0):

  • The new regression failed on unchanged source: isNumeric("n1", {"locale":"de-CH"}) passed but should error.
  • Baseline npm test: 323 passing.
  • Final npm test: 325 passing; all generated builds and ESLint passed; statements, lines, and functions remain at 100% coverage.
  • git diff --check passed.

Tests ran with HOME and npm cache redirected to writable temporary directories. No checks were disabled.

Prepared with OpenAI Codex. The reproduction and local checks above were executed in the development environment.

Checklist

  • Only related source, regression tests, and README changes
  • README updated
  • Regression tests written
  • Existing isDecimal behavior used as the error-handling precedent

@FanWu-ai
FanWu-ai marked this pull request as ready for review October 10, 2026 21:32
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