Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 'en-NZ' option for isMobilePhone function. #452

Merged
merged 2 commits into from
Nov 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ $ bower install validator-js
- **isJSON(str)** - check if the string is valid JSON (note: uses JSON.parse).
- **isLength(str, min [, max])** - check if the string's length falls in a range. Note: this function takes into account surrogate pairs.
- **isLowercase(str)** - check if the string is lowercase.
- **isMobilePhone(str, locale)** - check if the string is a mobile phone number, (locale is one of `['zh-CN', 'zh-TW', 'en-ZA', 'en-AU', 'en-HK', 'pt-PT', 'fr-FR', 'el-GR', 'en-GB', 'en-US', 'en-ZM', 'ru-RU', 'nb-NO', 'nn-NO', 'vi-VN']`).
- **isMobilePhone(str, locale)** - check if the string is a mobile phone number, (locale is one of `['zh-CN', 'zh-TW', 'en-ZA', 'en-AU', 'en-HK', 'pt-PT', 'fr-FR', 'el-GR', 'en-GB', 'en-US', 'en-ZM', 'ru-RU', 'nb-NO', 'nn-NO', 'vi-VN', 'en-NZ']`).
- **isMongoId(str)** - check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid].
- **isMultibyte(str)** - check if the string contains one or more multibyte chars.
- **isNull(str)** - check if the string is null.
Expand Down
22 changes: 22 additions & 0 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,28 @@ describe('Validators', function () {
args: ['ru-RU']
});

test({
validator: 'isMobilePhone'
, valid: [
'+6427987035'
, '642240512347'
, '0293981646'
, '029968425'
]
, invalid: [
'12345'
, ''
, 'Vml2YW11cyBmZXJtZtesting123'
, '+642956696123566'
, '+02119620856'
, '+9676338855'
, '19676338855'
, '6676338855'
, '+99676338855'
],
args: ['en-NZ']
});

var norwegian = {
valid: [
'+4796338855'
Expand Down
3 changes: 2 additions & 1 deletion validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@
'ru-RU': /^(\+?7|8)?9\d{9}$/,
'nb-NO': /^(\+?47)?[49]\d{7}$/,
'nn-NO': /^(\+?47)?[49]\d{7}$/,
'vi-VN': /^(0|\+?84)?((1(2([0-9])|6([2-9])|88|99))|(9((?!5)[0-9])))([0-9]{7})$/
'vi-VN': /^(0|\+?84)?((1(2([0-9])|6([2-9])|88|99))|(9((?!5)[0-9])))([0-9]{7})$/,
'en-NZ': /^(\+?64|0)2\d{7,9}$/
};

// from http://goo.gl/0ejHHW
Expand Down
Loading