diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index 2362807c5..444de5bc1 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -82,7 +82,7 @@ const phones = { 'nl-NL': /^(((\+|00)?31\(0\))|((\+|00)?31)|0)6{1}\d{8}$/, 'nn-NO': /^(\+?47)?[49]\d{7}$/, 'pl-PL': /^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/, - '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-BR': /^((\+?55\ ?[1-9]{2}\ ?)|(\+?55\ ?\([1-9]{2}\)\ ?)|(0[1-9]{2}\ ?)|(\([1-9]{2}\)\ ?)|([1-9]{2}\ ?))((\d{4}\-?\d{4})|(9[2-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}$/, diff --git a/test/validators.js b/test/validators.js index 824ee3302..0bfc8c9cb 100755 --- a/test/validators.js +++ b/test/validators.js @@ -5174,12 +5174,14 @@ describe('Validators', () => { { locale: 'pt-BR', valid: [ - '+55-12-996551215', - '+55-15-97661234', - '55-17-96332-2155', - '55-17-6332-2155', - '55-15-976612345', - '55-15-75661234', + '+55 12 996551215', + '+55 15 97661234', + '+55 (12) 996551215', + '+55 (15) 97661234', + '55 (17) 96332-2155', + '55 (17) 6332-2155', + '55 15 976612345', + '55 15 75661234', '+5512984567890', '+551283456789', '5512984567890', @@ -5188,15 +5190,29 @@ describe('Validators', () => { '01593456987', '022995678947', '02299567894', + '(22)99567894', + '(22)9956-7894', + '(22) 99567894', + '(22) 9956-7894', + '(22)999567894', + '(22)99956-7894', + '(22) 999567894', + '(22) 99956-7894', + '(11) 94123-4567', ], invalid: [ '0819876543', - '08158765432', - '+55-15-7566123', - '+017-123456789', + '+55 15 7566123', + '+017 123456789', '5501599623874', '+55012962308', - '+55-015-1234-3214', + '+55 015 1234-3214', + '+55 11 91431-4567', + '+55 (11) 91431-4567', + '+551191431-4567', + '5511914314567', + '5511912345678', + '(11) 91431-4567', ], }, {