Skip to content

Commit 3863033

Browse files
committed
Merge pull request #452 from grawlinson/master
Added 'en-NZ' option for isMobilePhone function.
2 parents 3dbb0cf + a43a80c commit 3863033

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ $ bower install validator-js
6464
- **isJSON(str)** - check if the string is valid JSON (note: uses JSON.parse).
6565
- **isLength(str, min [, max])** - check if the string's length falls in a range. Note: this function takes into account surrogate pairs.
6666
- **isLowercase(str)** - check if the string is lowercase.
67-
- **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']`).
67+
- **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']`).
6868
- **isMongoId(str)** - check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid].
6969
- **isMultibyte(str)** - check if the string contains one or more multibyte chars.
7070
- **isNull(str)** - check if the string is null.

test/validators.js

+22
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,28 @@ describe('Validators', function () {
15311531
args: ['ru-RU']
15321532
});
15331533

1534+
test({
1535+
validator: 'isMobilePhone'
1536+
, valid: [
1537+
'+6427987035'
1538+
, '642240512347'
1539+
, '0293981646'
1540+
, '029968425'
1541+
]
1542+
, invalid: [
1543+
'12345'
1544+
, ''
1545+
, 'Vml2YW11cyBmZXJtZtesting123'
1546+
, '+642956696123566'
1547+
, '+02119620856'
1548+
, '+9676338855'
1549+
, '19676338855'
1550+
, '6676338855'
1551+
, '+99676338855'
1552+
],
1553+
args: ['en-NZ']
1554+
});
1555+
15341556
var norwegian = {
15351557
valid: [
15361558
'+4796338855'

validator.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@
9595
'ru-RU': /^(\+?7|8)?9\d{9}$/,
9696
'nb-NO': /^(\+?47)?[49]\d{7}$/,
9797
'nn-NO': /^(\+?47)?[49]\d{7}$/,
98-
'vi-VN': /^(0|\+?84)?((1(2([0-9])|6([2-9])|88|99))|(9((?!5)[0-9])))([0-9]{7})$/
98+
'vi-VN': /^(0|\+?84)?((1(2([0-9])|6([2-9])|88|99))|(9((?!5)[0-9])))([0-9]{7})$/,
99+
'en-NZ': /^(\+?64|0)2\d{7,9}$/
99100
};
100101

101102
// from http://goo.gl/0ejHHW

0 commit comments

Comments
 (0)