From 700318acaa51b2e517d91df5c65e74aae9a90ec1 Mon Sep 17 00:00:00 2001 From: Gabriel Jacinto Date: Mon, 8 Feb 2016 13:31:24 -0200 Subject: [PATCH 1/2] Added validator for brazilian phone numbers --- CHANGELOG.md | 1 + test/validators.js | 19 +++++++++++++++++++ validator.js | 1 + 3 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64f2efb40..b964a7de2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ #### HEAD +- Added validator for brazilian phone numbers ([#489]) - Use [node-depd](https://github.com/dougwilson/nodejs-depd) to print deprecation notices ([#487](https://github.com/chriso/validator.js/issues/487)) diff --git a/test/validators.js b/test/validators.js index d79220737..465edc013 100644 --- a/test/validators.js +++ b/test/validators.js @@ -1459,6 +1459,25 @@ describe('Validators', function () { args: ['de-DE'] }); + test({ + validator: 'isMobilePhone' + , valid: [ + '55-17-3332-2155' + , '55-15-25661234' + , '551223456789' + , '01523456987' + , '022995678947' + , '+55-12-996551215' + ] + , invalid: [ + '+017-123456789' + , '5501599623874' + , '+55012962308' + , '+55-015-1234-3214' + ], + args: ['pt-BR'] + }); + test({ validator: 'isMobilePhone' , valid: [ diff --git a/validator.js b/validator.js index b765f9e58..c48fa9e2a 100644 --- a/validator.js +++ b/validator.js @@ -95,6 +95,7 @@ 'en-AU': /^(\+?61|0)4\d{8}$/, 'en-HK': /^(\+?852\-?)?[569]\d{3}\-?\d{4}$/, 'fr-FR': /^(\+?33|0)[67]\d{8}$/, + 'pt-BR': /^(\+?55|0)\-?[1-9]{2}\-?[2-9]{1}\d{3,4}\-?\d{4}$/, 'pt-PT': /^(\+?351)?9[1236]\d{7}$/, 'el-GR': /^(\+?30)?(69\d{8})$/, 'en-GB': /^(\+?44|0)7\d{9}$/, From c2ffa60d8d6585885d30b3fe1c53e9411d3f6fcc Mon Sep 17 00:00:00 2001 From: Gabriel Jacinto Date: Mon, 8 Feb 2016 13:40:39 -0200 Subject: [PATCH 2/2] Add pull request link --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b964a7de2..e47ca8223 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ #### HEAD -- Added validator for brazilian phone numbers ([#489]) +- Added validator for brazilian phone numbers ([#489](https://github.com/chriso/validator.js/pull/489)) - Use [node-depd](https://github.com/dougwilson/nodejs-depd) to print deprecation notices ([#487](https://github.com/chriso/validator.js/issues/487))