Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -2,7 +2,7 @@ import assertString from './util/assertString';

/* eslint-disable max-len */
const phones = {
'am-AM': /^(\+?374|0)((10|[9|7][0-9])\d{6}$|[2-4]\d{7}$)/,
'am-AM': /^(\+?374|0)(1[0125][2-9]|22[2346]|23[1-7]|24[2-69]|25[2-7]|26[1-9]|28[13-7]|3[12]2|(33|4[134]|55|77|88|9[13-689])\d)\d{5}$/,
Copy link
Member

Choose a reason for hiding this comment

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

nit: wondering if this regex could be any simpler?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think, I did all my best to combine and simplify similar parts.

Copy link
Member

Choose a reason for hiding this comment

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

We're still validating fixed phone numbers in this RegExp. See the section for 'Non-geographic number for mobile services' on page 12 for the only mobile phone numbers; https://www.itu.int/dms_pub/itu-t/oth/02/02/T020200000A0007PDFE.pdf

Suggested change
'am-AM': /^(\+?374|0)(1[0125][2-9]|22[2346]|23[1-7]|24[2-69]|25[2-7]|26[1-9]|28[13-7]|3[12]2|(33|4[134]|55|77|88|9[13-689])\d)\d{5}$/,
'am-AM': /^(\+?374|0)(33|4[134]|55|77|88|9[13-689])\d{6}$/,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@WikiRik,
pattern for fixed phone numbers has been removed, only mobile numbers are covered now there.
Thank you for suggestion

'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/,
'ar-BH': /^(\+?973)?(3|6)\d{7}$/,
'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,
Expand Down
12 changes: 9 additions & 3 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -6458,14 +6458,20 @@ describe('Validators', () => {
'022698763',
'37491987654',
'+37494567890',
'+37455123456',
'+37477123456',
'+37488123456',
],
invalid: [
'12345',
'+37411498855',
Copy link
Member

Choose a reason for hiding this comment

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

This is sort of minor "breaking change", can you move the removed test-cases to the valid side then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

'+37411498123',
'+37403498855',
'+37416498123',
'05614988556',
'',
'37456789000',
'37486789000',
'+37431312345',
'+37430312345',
'+37460123456',
],
},
{
Expand Down