Skip to content

fix(isMobilePhone): reject literal regex punctuation - #2970

Open
devwez wants to merge 1 commit into
validatorjs:masterfrom
devwez:fix/mobile-phone-literal-separators
Open

devwez wants to merge 1 commit into
validatorjs:masterfrom
devwez:fix/mobile-phone-literal-separators

Conversation

@devwez

@devwez devwez commented Nov 22, 2026

Copy link
Copy Markdown

The isMobilePhone patterns for ar-PS, es-HN, es-ES, and es-GT place | inside character classes, where it is a literal character rather than alternation. As a result, strings such as 05|1234567 (ar-PS) and |12345678 (es-ES) are accepted as phone numbers. The id-ID suffix class likewise accepts literal | and ?.

Remove these literal punctuation characters while preserving the existing accepted digits and whitespace. This does not update any numbering plan. Add five regression fixtures covering local and international forms, with valid controls. All five regression cases failed before the fix.

Validation: npm test passed, including the build, lint, and all 328 tests. Tested on Windows with the installed Node v27.0.0-alpha.0.0.0. git diff --check passed.

AI disclosure: OpenAI Codex (GPT-6) assisted with investigation, implementation, tests, and this description. Another Codex agent reviewed the diff and reran the tests; no independent human review is claimed.

Checklist

  • PR contains only related source changes and regression tests.
  • README updated where applicable: no API or numbering-plan documentation change is needed.
  • Tests written.
  • References provided where applicable: the defect follows directly from JavaScript character-class syntax and the included reproductions.

@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9ff3424) to head (1ab90fe).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2970   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2599      2599           
  Branches       658       658           
=========================================
  Hits          2599      2599           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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