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

isMobilePhone: add Chile locale and additional prefix for KE locale #1035

Merged
merged 2 commits into from May 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/isMobilePhone.js
Expand Up @@ -34,7 +34,7 @@ var phones = {
'en-HK': /^(\+?852\-?)?[456789]\d{3}\-?\d{4}$/,
'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
'en-KE': /^(\+?254|0)?[7]\d{8}$/,
'en-KE': /^(\+?254|0)(7|1)\d{8}$/,
Copy link
Member

Choose a reason for hiding this comment

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

Looks good. And also fixes a previous subtle bug that made 0/254 prefix optional when it should not be.

'en-MU': /^(\+?230|0)?\d{8}$/,
'en-NG': /^(\+?234|0)?[789]\d{9}$/,
'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
Expand All @@ -46,6 +46,7 @@ var phones = {
'en-US': /^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,
'en-ZA': /^(\+?27|0)\d{9}$/,
'en-ZM': /^(\+?26)?09[567]\d{7}$/,
'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/,
'es-ES': /^(\+?34)?(6\d{1}|7[1234])\d{7}$/,
'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
Expand Down
3 changes: 2 additions & 1 deletion src/lib/isMobilePhone.js
Expand Up @@ -24,7 +24,7 @@ const phones = {
'en-HK': /^(\+?852\-?)?[456789]\d{3}\-?\d{4}$/,
'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
'en-KE': /^(\+?254|0)?[7]\d{8}$/,
'en-KE': /^(\+?254|0)(7|1)\d{8}$/,
'en-MU': /^(\+?230|0)?\d{8}$/,
'en-NG': /^(\+?234|0)?[789]\d{9}$/,
'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
Expand All @@ -36,6 +36,7 @@ const phones = {
'en-US': /^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,
'en-ZA': /^(\+?27|0)\d{9}$/,
'en-ZM': /^(\+?26)?09[567]\d{7}$/,
'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/,
'es-ES': /^(\+?34)?(6\d{1}|7[1234])\d{7}$/,
'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
Expand Down
19 changes: 19 additions & 0 deletions test/validators.js
Expand Up @@ -3814,6 +3814,9 @@ describe('Validators', () => {
'254728590234',
'0733346543',
'0700459022',
'0110934567',
'+254110456794',
'254198452389',
],
invalid: [
'999',
Expand Down Expand Up @@ -4140,6 +4143,22 @@ describe('Validators', () => {
'0533803765',
],
},
{
locale: 'es-CL',
valid: [
'+56733875615',
'56928590234',
'0928590294',
'0208590294',
],
invalid: [
'1234',
'+5633875615',
'563875615',
'56109834567',
'56069834567',
],
},
{
locale: 'es-ES',
valid: [
Expand Down
3 changes: 2 additions & 1 deletion validator.js
Expand Up @@ -1295,7 +1295,7 @@ var phones = {
'en-HK': /^(\+?852\-?)?[456789]\d{3}\-?\d{4}$/,
'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
'en-KE': /^(\+?254|0)?[7]\d{8}$/,
'en-KE': /^(\+?254|0)(7|1)\d{8}$/,
'en-MU': /^(\+?230|0)?\d{8}$/,
'en-NG': /^(\+?234|0)?[789]\d{9}$/,
'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
Expand All @@ -1307,6 +1307,7 @@ var phones = {
'en-US': /^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,
'en-ZA': /^(\+?27|0)\d{9}$/,
'en-ZM': /^(\+?26)?09[567]\d{7}$/,
'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/,
'es-ES': /^(\+?34)?(6\d{1}|7[1234])\d{7}$/,
'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
Expand Down
2 changes: 1 addition & 1 deletion validator.min.js

Large diffs are not rendered by default.