Skip to content

Commit

Permalink
fix: fixed spaninsh postal code and mobile number regex (#1370)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubiin authored Jul 2, 2020
1 parent a3cddc1 commit a0a2e77
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const phones = {
'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/,
'es-CR': /^(\+506)?[2-8]\d{7}$/,
'es-EC': /^(\+?593|0)([2-7]|9[2-9])\d{7}$/,
'es-ES': /^(\+?34)?(6\d{1}|7[1234])\d{7}$/,
'es-ES': /^(\+?34)?[6|7]\d{8}$/,
'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
'es-PA': /^(\+?507)\d{7,8}$/,
'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/isPostalCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const patterns = {
DK: fourDigit,
DZ: fiveDigit,
EE: fiveDigit,
ES: fiveDigit,
ES: /^(5[0-2]{1}|[0-4]{1}\d{1})\d{3}$/,
FI: fiveDigit,
FR: /^\d{2}\s?\d{3}$/,
GB: /^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,
Expand Down
24 changes: 20 additions & 4 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -5945,10 +5945,10 @@ describe('Validators', () => {
'65478932',
'+346547893210',
'6547893210',
'+34704789321',
'704789321',
'+34754789321',
'754789321',
'+3470478932',
'7047893210',
'+34854789321',
'7547893219',
],
},
{
Expand Down Expand Up @@ -8142,6 +8142,22 @@ describe('Validators', () => {
'V5K 0A1',
],
},
{
locale: 'ES',
valid: [
'01001',
'52999',
'27880',
],
invalid: [
'123',
'1234',
'53000',
'052999',
'0123',
'abcde',
],
},
{
locale: 'JP',
valid: [
Expand Down

0 comments on commit a0a2e77

Please sign in to comment.