Skip to content

Commit b30c2ca

Browse files
austenpayanchriso
authored andcommittedJan 10, 2019
feat(isMobilePhone): add Ireland locale (en-IE) (#958)
* Add Ireland locale (en-IE) to regex collection in isMobilePhone * Update README to display Irish locale * Add tests for isMobilePhone en-IE locale regex (Ireland)
1 parent 5ca54d2 commit b30c2ca

File tree

6 files changed

+26
-2
lines changed

6 files changed

+26
-2
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Validator | Description
120120
**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.
121121
**isMD5(str)** | check if the string is a MD5 hash.
122122
**isMimeType(str)** | check if the string matches to a valid [MIME type](https://en.wikipedia.org/wiki/Media_type) format
123-
**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-GH', '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`.
123+
**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-GH', 'en-HK', 'en-IE', '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`.
124124
**isMongoId(str)** | check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid].
125125
**isMultibyte(str)** | check if the string contains one or more multibyte chars.
126126
**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
@@ -32,6 +32,7 @@ var phones = {
3232
'en-GB': /^(\+?44|0)7\d{9}$/,
3333
'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28)\d{7}$/,
3434
'en-HK': /^(\+?852\-?)?[456789]\d{3}\-?\d{4}$/,
35+
'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
3536
'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
3637
'en-KE': /^(\+?254|0)?[7]\d{8}$/,
3738
'en-MU': /^(\+?230|0)?\d{8}$/,

‎src/lib/isMobilePhone.js

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const phones = {
2222
'en-GB': /^(\+?44|0)7\d{9}$/,
2323
'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28)\d{7}$/,
2424
'en-HK': /^(\+?852\-?)?[456789]\d{3}\-?\d{4}$/,
25+
'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
2526
'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
2627
'en-KE': /^(\+?254|0)?[7]\d{8}$/,
2728
'en-MU': /^(\+?230|0)?\d{8}$/,

‎test/validators.js

+21
Original file line numberDiff line numberDiff line change
@@ -3735,6 +3735,27 @@ describe('Validators', () => {
37353735
'+852-1234-56789',
37363736
],
37373737
},
3738+
{
3739+
locale: 'en-IE',
3740+
valid: [
3741+
'+353871234567',
3742+
'353831234567',
3743+
'353851234567',
3744+
'353861234567',
3745+
'353871234567',
3746+
'353881234567',
3747+
'353891234567',
3748+
'0871234567',
3749+
'0851234567',
3750+
],
3751+
invalid: [
3752+
'999',
3753+
'+353341234567',
3754+
'+33589484858',
3755+
'353841234567',
3756+
'353811234567',
3757+
],
3758+
},
37383759
{
37393760
locale: 'en-KE',
37403761
valid: [

‎validator.js

+1
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,7 @@ var phones = {
13831383
'en-GB': /^(\+?44|0)7\d{9}$/,
13841384
'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28)\d{7}$/,
13851385
'en-HK': /^(\+?852\-?)?[456789]\d{3}\-?\d{4}$/,
1386+
'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
13861387
'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
13871388
'en-KE': /^(\+?254|0)?[7]\d{8}$/,
13881389
'en-MU': /^(\+?230|0)?\d{8}$/,

‎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.