Skip to content

Commit 06f9919

Browse files
fix: Modify pattern of pt-Br regex
- A Brazilian cellphone number can start with 1 after its country code and local code - Fix test case to accept +55 11 91431-4567 and similar ones as valid Signed-off-by: Matheus Gomes <matheusnascgomes@gmail.com>
1 parent c1b21a9 commit 06f9919

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/lib/isMobilePhone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const phones = {
112112
'nl-NL': /^(((\+|00)?31\(0\))|((\+|00)?31)|0)6{1}\d{8}$/,
113113
'nn-NO': /^(\+?47)?[49]\d{7}$/,
114114
'pl-PL': /^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/,
115-
'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}))$/,
115+
'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[1-9]{1}\d{3}\-?\d{4}))$/,
116116
'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
117117
'pt-AO': /^(\+244)\d{9}$/,
118118
'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/,

test/validators.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6457,6 +6457,12 @@ describe('Validators', () => {
64576457
'(22) 999567894',
64586458
'(22) 99956-7894',
64596459
'(11) 94123-4567',
6460+
'(11) 91431-4567',
6461+
'+55 (11) 91431-4567',
6462+
'+55 11 91431-4567',
6463+
'+551191431-4567',
6464+
'5511914314567',
6465+
'5511912345678',
64606466
],
64616467
invalid: [
64626468
'0819876543',
@@ -6465,12 +6471,12 @@ describe('Validators', () => {
64656471
'5501599623874',
64666472
'+55012962308',
64676473
'+55 015 1234-3214',
6468-
'+55 11 91431-4567',
6469-
'+55 (11) 91431-4567',
6470-
'+551191431-4567',
6471-
'5511914314567',
6472-
'5511912345678',
6473-
'(11) 91431-4567',
6474+
'+55 11 90431-4567',
6475+
'+55 (11) 90431-4567',
6476+
'+551190431-4567',
6477+
'5511904314567',
6478+
'5511902345678',
6479+
'(11) 90431-4567',
64746480
],
64756481
},
64766482
{

0 commit comments

Comments
 (0)