Skip to content

Commit 5b62a91

Browse files
authored
Merge pull request #627 from arpadszasz/master
Add support for Romanian mobile phone numbers
2 parents 0024404 + 8afd190 commit 5b62a91

File tree

6 files changed

+35
-2
lines changed

6 files changed

+35
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Passing anything other than a string is an error.
8888
- **isLowercase(str)** - check if the string is lowercase.
8989
- **isMACAddress(str)** - check if the string is a MAC address.
9090
- **isMD5(str)** - check if the string is a MD5 hash.
91-
- **isMobilePhone(str, locale)** - check if the string is a mobile phone number, (locale is one of `['ar-DZ', 'ar-SA', 'ar-SY', 'cs-CZ', 'de-DE', 'da-DK', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NG', 'en-NZ', 'en-US', 'en-CA', 'en-ZA', 'en-ZM', 'es-ES', 'fi-FI', 'fr-FR', 'he-IL', 'hu-HU', 'it-IT', 'ja-JP', 'ms-MY', 'nb-NO', 'nn-NO', 'pl-PL', 'pt-PT', 'ru-RU', 'sr-RS', 'tr-TR', 'vi-VN', 'zh-CN', 'zh-TW']`).
91+
- **isMobilePhone(str, locale)** - check if the string is a mobile phone number, (locale is one of `['ar-DZ', 'ar-SA', 'ar-SY', 'cs-CZ', 'de-DE', 'da-DK', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NG', 'en-NZ', 'en-US', 'en-CA', 'en-ZA', 'en-ZM', 'es-ES', 'fi-FI', 'fr-FR', 'he-IL', 'hu-HU', 'it-IT', 'ja-JP', 'ms-MY', 'nb-NO', 'nn-NO', 'pl-PL', 'pt-PT', 'ro-RO', 'ru-RU', 'sr-RS', 'tr-TR', 'vi-VN', 'zh-CN', 'zh-TW']`).
9292
- **isMongoId(str)** - check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid].
9393
- **isMultibyte(str)** - check if the string contains one or more multibyte chars.
9494
- **isNumeric(str)** - check if the string contains only numbers.

lib/isMobilePhone.js

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var phones = {
4343
'pl-PL': /^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/,
4444
'pt-BR': /^(\+?55|0)\-?[1-9]{2}\-?[2-9]{1}\d{3,4}\-?\d{4}$/,
4545
'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
46+
'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/,
4647
'ru-RU': /^(\+?7|8)?9\d{9}$/,
4748
'sr-RS': /^(\+3816|06)[- \d]{5,9}$/,
4849
'tr-TR': /^(\+?90|0)?5\d{9}$/,

src/lib/isMobilePhone.js

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const phones = {
3232
'pl-PL': /^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/,
3333
'pt-BR': /^(\+?55|0)\-?[1-9]{2}\-?[2-9]{1}\d{3,4}\-?\d{4}$/,
3434
'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
35+
'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/,
3536
'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,
3637
'ru-RU': /^(\+?7|8)?9\d{9}$/,
3738
'sr-RS': /^(\+3816|06)[- \d]{5,9}$/,

test/validators.js

+30
Original file line numberDiff line numberDiff line change
@@ -2887,6 +2887,36 @@ describe('Validators', function () {
28872887
],
28882888
args: ['nl-BE'],
28892889
});
2890+
2891+
test({
2892+
validator: 'isMobilePhone',
2893+
valid: [
2894+
'+40740123456',
2895+
'+40 740123456',
2896+
'+40740 123 456',
2897+
'+40740.123.456',
2898+
'+40740-123-456',
2899+
'40740123456',
2900+
'40 740123456',
2901+
'40740 123 456',
2902+
'40740.123.456',
2903+
'40740-123-456',
2904+
'0740123456',
2905+
'0740/123456',
2906+
'0740 123 456',
2907+
'0740.123.456',
2908+
'0740-123-456',
2909+
],
2910+
invalid: [
2911+
'',
2912+
'Vml2YW11cyBmZXJtZtesting123',
2913+
'123456',
2914+
'740123456',
2915+
'+40640123456',
2916+
'+40210123456',
2917+
],
2918+
args: ['ro-RO'],
2919+
});
28902920
});
28912921

28922922
it('should validate currency', function () {

validator.js

+1
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,7 @@
11111111
'pl-PL': /^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/,
11121112
'pt-BR': /^(\+?55|0)\-?[1-9]{2}\-?[2-9]{1}\d{3,4}\-?\d{4}$/,
11131113
'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
1114+
'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/,
11141115
'ru-RU': /^(\+?7|8)?9\d{9}$/,
11151116
'sr-RS': /^(\+3816|06)[- \d]{5,9}$/,
11161117
'tr-TR': /^(\+?90|0)?5\d{9}$/,

validator.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)