Skip to content

fix(isMobilePhone): update fr-BJ to Benin's 10-digit numbering plan - #2945

Open
egbavou wants to merge 1 commit into
validatorjs:masterfrom
egbavou:fix/fr-bj-mobile-phone
Open

egbavou wants to merge 1 commit into
validatorjs:masterfrom
egbavou:fix/fr-bj-mobile-phone

Conversation

@egbavou

@egbavou egbavou commented Oct 24, 2026

Copy link
Copy Markdown

Benin moved from 8-digit to 10-digit phone numbers on 30 November 2024: every number got the 01 prefix, and 8-digit numbers stopped working when the parallel-running period ended on 29 December 2024.

The fr-BJ rule (/^(\+229)\d{8}$/) still expects 8 digits. As a result, isMobilePhone rejects every current Beninese mobile number, such as +2290197123456, and accepts 8-digit numbers that no longer exist.

This PR:

  • matches 01 followed by the mobile ranges, using the same pattern as Google libphonenumber's BJ mobile metadata: 01(2[5-9]|[4-69]\d)\d{6};
  • excludes the fixed-line ranges 0120–0124;
  • keeps +229 mandatory, as before;
  • replaces the valid test numbers with mobile numbers. The old ones, +22920… to +22923…, were fixed-line numbers;
  • adds invalid cases: old 8-digit numbers, new fixed-line numbers, unallocated ranges, wrong lengths, and a missing +.

The ITU table lists 0125–0129 as "fixed and mobile" series. Google classifies them as fixed-line-or-mobile and includes them in its mobile pattern, so this PR accepts them too.

References

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable): not applicable; the locale list does not change
  • Tests written (where applicable)
  • References provided in PR (where applicable)

@codecov

codecov Bot commented Oct 24, 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 (3684ae9).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2945   +/-   ##
=========================================
  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.

1 participant