Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(isMobilePhone): update phone regex for Cameroon fr-CM #2454

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const phones = {
'fr-BF': /^(\+226|0)[67]\d{7}$/,
'fr-BJ': /^(\+229)\d{8}$/,
'fr-CD': /^(\+?243|0)?(8|9)\d{8}$/,
'fr-CM': /^(\+?237)6[0-9]{8}$/,
'fr-CM': /^(\+?237)(6|2)[0-9]{8}$/,
Copy link
Member

Choose a reason for hiding this comment

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

This change is not needed as far as I can see. A number starting with 2 is not for mobile phone numbers, only fixed numbers (which we don't validate here). We can improve this regular expression to make it more strict though.

The latest ITU information (which is my primary source) is from 2014, so it might be outdated;
https://www.itu.int/oth/T0202000024/en

Copy link
Author

Choose a reason for hiding this comment

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

I had some work done for a client with a modem who's number started with 2. The modem uses LTE for connectivity so would that be a fixed or mobile classification?

'fr-FR': /^(\+?33|0)[67]\d{8}$/,
'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/,
'fr-GP': /^(\+?590|0|00590)[67]\d{8}$/,
Expand Down
24 changes: 24 additions & 0 deletions test/validators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10667,6 +10667,30 @@ describe('Validators', () => {
args: ['any'],
});


// strict mode
// isMobile fr-CM
test({
validator: 'isMobilePhone',
valid: [
// Camtel Fixed
'+237222222222',
// Mobile
'+237698765432',
'+237658765432',
'+237678765432',
'+237677465432',
],
invalid: [
'254728530234',
'0728530234',
'+728530234',
'766667206',
'0766670206',
],
args: ['any', { strictMode: true }],
});

// strict mode
test({
validator: 'isMobilePhone',
Expand Down
Loading