Skip to content

Commit

Permalink
Merge pull request #878 from ftrevo/improvement/pt-BR-mobile-phone-va…
Browse files Browse the repository at this point in the history
…lidation

Improving pt-BR mobile phone validation
  • Loading branch information
chriso authored Aug 10, 2018
2 parents f003962 + e1f83be commit ca808e4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var phones = {
'nl-BE': /^(\+?32|0)4?\d{8}$/,
'nn-NO': /^(\+?47)?[49]\d{7}$/,
'pl-PL': /^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/,
'pt-BR': /^(\+?55|0)\-?[1-9]{2}\-?[2-9]{1}\d{3,4}\-?\d{4}$/,
'pt-BR': /(?=^(\+?5{2}\-?|0)[1-9]{2}\-?\d{4}\-?\d{4}$)(^(\+?5{2}\-?|0)[1-9]{2}\-?[6-9]{1}\d{3}\-?\d{4}$)|(^(\+?5{2}\-?|0)[1-9]{2}\-?9[6-9]{1}\d{3}\-?\d{4}$)/,
'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/,
'ru-RU': /^(\+?7|8)?9\d{9}$/,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const phones = {
'nl-BE': /^(\+?32|0)4?\d{8}$/,
'nn-NO': /^(\+?47)?[49]\d{7}$/,
'pl-PL': /^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/,
'pt-BR': /^(\+?55|0)\-?[1-9]{2}\-?[2-9]{1}\d{3,4}\-?\d{4}$/,
'pt-BR': /(?=^(\+?5{2}\-?|0)[1-9]{2}\-?\d{4}\-?\d{4}$)(^(\+?5{2}\-?|0)[1-9]{2}\-?[6-9]{1}\d{3}\-?\d{4}$)|(^(\+?5{2}\-?|0)[1-9]{2}\-?9[6-9]{1}\d{3}\-?\d{4}$)/,
'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/,
'ru-RU': /^(\+?7|8)?9\d{9}$/,
Expand Down
21 changes: 16 additions & 5 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -3451,14 +3451,25 @@ describe('Validators', () => {
{
locale: 'pt-BR',
valid: [
'55-17-3332-2155',
'55-15-25661234',
'551223456789',
'01523456987',
'022995678947',
'+55-12-996551215',
'+55-15-97661234',
'55-17-96332-2155',
'55-17-6332-2155',
'55-15-976612345',
'55-15-75661234',
'+5512984567890',
'+551283456789',
'5512984567890',
'551283456789',
'015994569878',
'01593456987',
'022995678947',
'02299567894',
],
invalid: [
'0819876543',
'08158765432',
'+55-15-7566123',
'+017-123456789',
'5501599623874',
'+55012962308',
Expand Down

0 comments on commit ca808e4

Please sign in to comment.