Skip to content

Commit 209a801

Browse files
bubenkoffchriso
authored andcommittedNov 7, 2018
feat(isMobilePhone): add en-MU locale (Mauritian) (#925)
1 parent c12af3c commit 209a801

File tree

6 files changed

+28
-2
lines changed

6 files changed

+28
-2
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Validator | Description
106106
**isMACAddress(str)** | check if the string is a MAC address.<br/><br/>`options` is an object which defaults to `{no_colons: false}`. If `no_colons` is true, the validator will allow MAC addresses without the colons.
107107
**isMD5(str)** | check if the string is a MD5 hash.
108108
**isMimeType(str)** | check if the string matches to a valid [MIME type](https://en.wikipedia.org/wiki/Media_type) format
109-
**isMobilePhone(str [, locale [, options]])** | check if the string is a mobile phone number,<br/><br/>(locale is either an array of locales (e.g `['sk-SK', 'sr-RS']`) OR one of `['ar-AE', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-SA', 'ar-SY', 'ar-TN', 'be-BY', 'bg-BG', 'bn-BD', 'cs-CZ', 'de-DE', 'da-DK', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-HK', 'en-IN', 'en-KE', 'en-NG', 'en-NZ', 'en-RW', 'en-SG', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'en-PK', 'es-ES', 'es-MX', 'es-UY', 'et-EE', 'fa-IR', 'fi-FI', 'fr-FR', 'he-IL', 'hu-HU', 'it-IT', 'ja-JP', 'kk-KZ', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'nn-NO', 'pl-PL', 'pt-PT', 'pt-BR', 'ro-RO', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-TW']` OR defaults to 'any'. If 'any' or a falsey value is used, function will check if any of the locales match).<br/><br/>`options` is an optional object that can be supplied with the following keys: `strictMode`, if this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`. Locale list is `validator.isMobilePhoneLocales`.
109+
**isMobilePhone(str [, locale [, options]])** | check if the string is a mobile phone number,<br/><br/>(locale is either an array of locales (e.g `['sk-SK', 'sr-RS']`) OR one of `['ar-AE', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-SA', 'ar-SY', 'ar-TN', 'be-BY', 'bg-BG', 'bn-BD', 'cs-CZ', 'de-DE', 'da-DK', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-HK', 'en-IN', 'en-KE', 'en-MU', en-NG', 'en-NZ', 'en-RW', 'en-SG', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'en-PK', 'es-ES', 'es-MX', 'es-UY', 'et-EE', 'fa-IR', 'fi-FI', 'fr-FR', 'he-IL', 'hu-HU', 'it-IT', 'ja-JP', 'kk-KZ', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'nn-NO', 'pl-PL', 'pt-PT', 'pt-BR', 'ro-RO', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-TW']` OR defaults to 'any'. If 'any' or a falsey value is used, function will check if any of the locales match).<br/><br/>`options` is an optional object that can be supplied with the following keys: `strictMode`, if this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`. Locale list is `validator.isMobilePhoneLocales`.
110110
**isMongoId(str)** | check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid].
111111
**isMultibyte(str)** | check if the string contains one or more multibyte chars.
112112
**isNumeric(str [, options])** | check if the string contains only numbers.<br/><br/>`options` is an object which defaults to `{no_symbols: false}`. If `no_symbols` is true, the validator will reject numeric strings that feature a symbol (e.g. `+`, `-`, or `.`).

‎lib/isMobilePhone.js

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var phones = {
3333
'en-HK': /^(\+?852\-?)?[456789]\d{3}\-?\d{4}$/,
3434
'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
3535
'en-KE': /^(\+?254|0)?[7]\d{8}$/,
36+
'en-MU': /^(\+?230|0)?\d{8}$/,
3637
'en-NG': /^(\+?234|0)?[789]\d{9}$/,
3738
'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
3839
'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,

‎src/lib/isMobilePhone.js

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const phones = {
2323
'en-HK': /^(\+?852\-?)?[456789]\d{3}\-?\d{4}$/,
2424
'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
2525
'en-KE': /^(\+?254|0)?[7]\d{8}$/,
26+
'en-MU': /^(\+?230|0)?\d{8}$/,
2627
'en-NG': /^(\+?234|0)?[789]\d{9}$/,
2728
'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
2829
'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,

‎test/validators.js

+23
Original file line numberDiff line numberDiff line change
@@ -3955,6 +3955,29 @@ describe('Validators', () => {
39553955
'+99676338855',
39563956
],
39573957
},
3958+
{
3959+
locale: 'en-MU',
3960+
valid: [
3961+
'+23012341234',
3962+
'12341234',
3963+
'012341234',
3964+
],
3965+
invalid: [
3966+
'41234',
3967+
'',
3968+
'+230',
3969+
'+2301',
3970+
'+23012',
3971+
'+230123',
3972+
'+2301234',
3973+
'+23012341',
3974+
'+230123412',
3975+
'+2301234123',
3976+
'+230123412341',
3977+
'+2301234123412',
3978+
'+23012341234123',
3979+
],
3980+
},
39583981
{
39593982
locale: ['nb-NO', 'nn-NO'], // for multiple locales
39603983
valid: [

‎validator.js

+1
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,7 @@ var phones = {
13651365
'en-HK': /^(\+?852\-?)?[456789]\d{3}\-?\d{4}$/,
13661366
'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
13671367
'en-KE': /^(\+?254|0)?[7]\d{8}$/,
1368+
'en-MU': /^(\+?230|0)?\d{8}$/,
13681369
'en-NG': /^(\+?234|0)?[789]\d{9}$/,
13691370
'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
13701371
'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,

‎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)
Please sign in to comment.