Skip to content

Commit

Permalink
feat(isMobilePhone): add Chile locale and additional prefix for KE lo…
Browse files Browse the repository at this point in the history
…cale (#1035)

* isMobilePhone: add additional prefix for KE locale

* add Chile mobile number in isMobilePhone
  • Loading branch information
ezkemboi authored and profnandaa committed May 24, 2019
1 parent 90cc022 commit eb0bbba
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/isMobilePhone.js
Original file line number Diff line number Diff line change
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}$/,
'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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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.

0 comments on commit eb0bbba

Please sign in to comment.