From 4b1079533290de75946db7837919eaebcd404a93 Mon Sep 17 00:00:00 2001 From: Nando Ferraz Date: Fri, 14 May 2021 12:12:32 -0300 Subject: [PATCH] Changed mobile phone number pt-br regex to accept number 1 after 9 --- src/lib/isMobilePhone.js | 2 +- test/validators.js | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index 95b568547..4b16fa94e 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -98,7 +98,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': /^((\+?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-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}))$/, 'pt-PT': /^(\+?351)?9[1236]\d{7}$/, 'pt-AO': /^(\+244)\d{9}$/, 'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/, diff --git a/test/validators.js b/test/validators.js index 56e581d39..903c879dc 100644 --- a/test/validators.js +++ b/test/validators.js @@ -5908,12 +5908,15 @@ describe('Validators', () => { '+55 (15) 97661234', '55 (17) 96332-2155', '55 (17) 6332-2155', + '55 (11) 910007890', '55 15 976612345', '55 15 75661234', '+5512984567890', '+551283456789', + '+5511910007890', '5512984567890', '551283456789', + '5511910007890', '015994569878', '01593456987', '022995678947', @@ -5927,6 +5930,7 @@ describe('Validators', () => { '(22) 999567894', '(22) 99956-7894', '(11) 94123-4567', + '(11) 91000-7890', ], invalid: [ '0819876543', @@ -5935,12 +5939,12 @@ describe('Validators', () => { '5501599623874', '+55012962308', '+55 015 1234-3214', - '+55 11 91431-4567', - '+55 (11) 91431-4567', - '+551191431-4567', - '5511914314567', - '5511912345678', - '(11) 91431-4567', + '+55 11 90431-4567', + '+55 (11) 90431-4567', + '+551190431-4567', + '5511904314567', + '5511902345678', + '(11) 90431-4567', ], }, {