diff --git a/CHANGELOG.md b/CHANGELOG.md index 64f2efb40..e47ca8223 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ #### HEAD +- 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)) 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}$/,