Skip to content

Commit 328cd7a

Browse files
committed
Merge branch 'paragasu-master'
2 parents 7742d69 + f066fe2 commit 328cd7a

File tree

6 files changed

+60
-31
lines changed

6 files changed

+60
-31
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Passing anything other than a string is an error.
8484
- **isLength(str, options)** - check if the string's length falls in a range. `options` is an object which defaults to `{min:0, max: undefined}`. Note: this function takes into account surrogate pairs.
8585
- **isLowercase(str)** - check if the string is lowercase.
8686
- **isMACAddress(str)** - check if the string is a MAC address.
87-
- **isMobilePhone(str, locale)** - check if the string is a mobile phone number, (locale is one of `['ar-SY', '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', 'en-IN', 'es-ES', 'de-DE', 'fi-FI']`).
87+
- **isMobilePhone(str, locale)** - check if the string is a mobile phone number, (locale is one of `['ar-SY', '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', 'en-IN', 'es-ES', 'de-DE', 'fi-FI', 'ms-MY']`).
8888
- **isMongoId(str)** - check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid].
8989
- **isMultibyte(str)** - check if the string contains one or more multibyte chars.
9090
- **isNull(str)** - check if the string is null (has a length of zero).

lib/isMobilePhone.js

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var phones = {
2727
'es-ES': /^(\+?34)?(6\d{1}|7[1234])\d{7}$/,
2828
'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5)?|50)\s?(\d\s?){4,8}\d$/,
2929
'fr-FR': /^(\+?33|0)[67]\d{8}$/,
30+
'ms-MY': /^(\+?6?01){1}(([145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,
3031
'nb-NO': /^(\+?47)?[49]\d{7}$/,
3132
'nn-NO': /^(\+?47)?[49]\d{7}$/,
3233
'pt-BR': /^(\+?55|0)\-?[1-9]{2}\-?[2-9]{1}\d{3,4}\-?\d{4}$/,

src/lib/isMobilePhone.js

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const phones = {
1616
'es-ES': /^(\+?34)?(6\d{1}|7[1234])\d{7}$/,
1717
'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5)?|50)\s?(\d\s?){4,8}\d$/,
1818
'fr-FR': /^(\+?33|0)[67]\d{8}$/,
19+
'ms-MY': /^(\+?6?01){1}(([145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,
1920
'nb-NO': /^(\+?47)?[49]\d{7}$/,
2021
'nn-NO': /^(\+?47)?[49]\d{7}$/,
2122
'pt-BR': /^(\+?55|0)\-?[1-9]{2}\-?[2-9]{1}\d{3,4}\-?\d{4}$/,

test/validators.js

+55-29
Original file line numberDiff line numberDiff line change
@@ -2063,36 +2063,62 @@ describe('Validators', function () {
20632063
],
20642064
args: ['es-ES'],
20652065
});
2066-
});
20672066

2068-
test({
2069-
validator: 'isMobilePhone',
2070-
valid: [
2071-
'+358505557171',
2072-
'0455571',
2073-
'0505557171',
2074-
'358505557171',
2075-
'04412345',
2076-
'0457 123 45 67',
2077-
'+358457 123 45 67',
2078-
'+358 50 555 7171',
2079-
],
2080-
invalid: [
2081-
'12345',
2082-
'',
2083-
'045557',
2084-
'045555717112312332423423421',
2085-
'Vml2YW11cyBmZXJtZtesting123',
2086-
'010-38238383',
2087-
'+3-585-0555-7171',
2088-
'+9676338855',
2089-
'19676338855',
2090-
'6676338855',
2091-
'+99676338855',
2092-
'044123',
2093-
'019123456789012345678901',
2094-
],
2095-
args: ['fi-FI'],
2067+
test({
2068+
validator: 'isMobilePhone',
2069+
valid: [
2070+
'+358505557171',
2071+
'0455571',
2072+
'0505557171',
2073+
'358505557171',
2074+
'04412345',
2075+
'0457 123 45 67',
2076+
'+358457 123 45 67',
2077+
'+358 50 555 7171',
2078+
],
2079+
invalid: [
2080+
'12345',
2081+
'',
2082+
'045557',
2083+
'045555717112312332423423421',
2084+
'Vml2YW11cyBmZXJtZtesting123',
2085+
'010-38238383',
2086+
'+3-585-0555-7171',
2087+
'+9676338855',
2088+
'19676338855',
2089+
'6676338855',
2090+
'+99676338855',
2091+
'044123',
2092+
'019123456789012345678901',
2093+
],
2094+
args: ['fi-FI'],
2095+
});
2096+
2097+
test({
2098+
validator: 'isMobilePhone',
2099+
valid: [
2100+
'+60128228789',
2101+
'+60195830837',
2102+
'+6019-5830837',
2103+
'+6019-5830837',
2104+
'0128737867',
2105+
'01468987837',
2106+
'016-2838768',
2107+
'016 2838768',
2108+
],
2109+
invalid: [
2110+
'12345',
2111+
'601238788657',
2112+
'088387675',
2113+
'16-2838768',
2114+
'032551433',
2115+
'6088-387888',
2116+
'088-261987',
2117+
'1800-88-8687',
2118+
'088-320000',
2119+
],
2120+
args: ['ms-MY'],
2121+
});
20962122
});
20972123

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

validator.js

+1
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@
855855
'es-ES': /^(\+?34)?(6\d{1}|7[1234])\d{7}$/,
856856
'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5)?|50)\s?(\d\s?){4,8}\d$/,
857857
'fr-FR': /^(\+?33|0)[67]\d{8}$/,
858+
'ms-MY': /^(\+?6?01){1}(([145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,
858859
'nb-NO': /^(\+?47)?[49]\d{7}$/,
859860
'nn-NO': /^(\+?47)?[49]\d{7}$/,
860861
'pt-BR': /^(\+?55|0)\-?[1-9]{2}\-?[2-9]{1}\d{3,4}\-?\d{4}$/,

0 commit comments

Comments
 (0)