Skip to content

feat(isMobilePhone): Add Monaco mobile phone numbers support#2697

Open
tonienguix wants to merge 2 commits intovalidatorjs:masterfrom
tonienguix:tonienguix
Open

feat(isMobilePhone): Add Monaco mobile phone numbers support#2697
tonienguix wants to merge 2 commits intovalidatorjs:masterfrom
tonienguix:tonienguix

Conversation

@tonienguix
Copy link
Copy Markdown

feat(isMobilePhone): Add Monaco mobile phone numbers support

Added one line of code to provide support for Monaco prefixes:

'fr-MC': /^(\+?377)(4[456]\d{6}|6\d{8})$/,

The regex is based on this reference https://en.wikipedia.org/wiki/Telephone_numbers_in_Monaco

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Tests written (where applicable)
  • References provided in PR (where applicable)

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7a80797) to head (3558bee).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2697   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2586      2586           
  Branches       656       656           
=========================================
  Hits          2586      2586           

☔ View full report in Codecov by Sentry.
📢 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.

@rubiin rubiin requested review from WikiRik and Copilot and removed request for Copilot April 9, 2026 13:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new isMobilePhone locale to support Monaco (fr-MC) phone number validation, including documentation and tests, aligning with the project’s locale-driven regex approach.

Changes:

  • Added fr-MC regex to src/lib/isMobilePhone.js.
  • Added fr-MC fixtures to the isMobilePhone validator test suite.
  • Documented fr-MC in the README’s isMobilePhone locale list.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/lib/isMobilePhone.js Adds fr-MC locale regex to the phones map.
test/validators.test.js Adds fr-MC valid/invalid fixtures to the isMobilePhone test matrix.
README.md Includes fr-MC in the documented locale list for isMobilePhone.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

'fr-FR': /^(\+?33|0)[67]\d{8}$/,
'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/,
'fr-GP': /^(\+?590|0|00590)[67]\d{8}$/,
'fr-MC': /^(\+?377)(4[456]\d{6}|6\d{8})$/,
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fr-MC pattern mixes different national-number lengths: the 4[456]\d{6} branch matches 8 digits after 377, but the 6\d{8} branch matches 9 digits after 377. This inconsistency is likely unintended and will accept numbers with different lengths depending on prefix. Please verify Monaco’s mobile number length and adjust the regex (and corresponding fixtures) so both branches reflect the correct national significant number length.

Suggested change
'fr-MC': /^(\+?377)(4[456]\d{6}|6\d{8})$/,
'fr-MC': /^(\+?377)(4[456]\d{6}|6\d{7})$/,

Copilot uses AI. Check for mistakes.
Comment on lines +8855 to +8867
'+377612345678',
'+377698765432',
'37744123456',
'37745678901',
'37746234567',
'377612345678',
'377698765432',
],
invalid: [
'37743123456',
'+37747123456',
'+37741123456',
'+377512345678',
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added fr-MC fixtures treat +3776… numbers as having 9 digits after the country code (e.g. +377612345678), while +37744… numbers have 8 digits after the country code. This makes the fixture set internally inconsistent and tightly couples it to the current regex behavior. After confirming the correct Monaco number length, please update these test cases to use the correct digit count consistently.

Suggested change
'+377612345678',
'+377698765432',
'37744123456',
'37745678901',
'37746234567',
'377612345678',
'377698765432',
],
invalid: [
'37743123456',
'+37747123456',
'+37741123456',
'+377512345678',
'+37761234567',
'+37769876543',
'37744123456',
'37745678901',
'37746234567',
'37761234567',
'37769876543',
],
invalid: [
'37743123456',
'+37747123456',
'+37741123456',
'+377612345678',

Copilot uses AI. Check for mistakes.
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