Skip to content

Commit

Permalink
feat(isMobilePhone): add Ireland locale (en-IE) (#958)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
austenpayan authored and chriso committed Jan 10, 2019
1 parent 5ca54d2 commit b30c2ca
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -120,7 +120,7 @@ Validator | Description
**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.
**isMD5(str)** | check if the string is a MD5 hash.
**isMimeType(str)** | check if the string matches to a valid [MIME type](https://en.wikipedia.org/wiki/Media_type) format
**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`.
**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`.
**isMongoId(str)** | check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid].
**isMultibyte(str)** | check if the string contains one or more multibyte chars.
**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 `.`).
Expand Down
1 change: 1 addition & 0 deletions lib/isMobilePhone.js
Expand Up @@ -32,6 +32,7 @@ var phones = {
'en-GB': /^(\+?44|0)7\d{9}$/,
'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28)\d{7}$/,
'en-HK': /^(\+?852\-?)?[456789]\d{3}\-?\d{4}$/,
'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
'en-KE': /^(\+?254|0)?[7]\d{8}$/,
'en-MU': /^(\+?230|0)?\d{8}$/,
Expand Down
1 change: 1 addition & 0 deletions src/lib/isMobilePhone.js
Expand Up @@ -22,6 +22,7 @@ const phones = {
'en-GB': /^(\+?44|0)7\d{9}$/,
'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28)\d{7}$/,
'en-HK': /^(\+?852\-?)?[456789]\d{3}\-?\d{4}$/,
'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
'en-KE': /^(\+?254|0)?[7]\d{8}$/,
'en-MU': /^(\+?230|0)?\d{8}$/,
Expand Down
21 changes: 21 additions & 0 deletions test/validators.js
Expand Up @@ -3735,6 +3735,27 @@ describe('Validators', () => {
'+852-1234-56789',
],
},
{
locale: 'en-IE',
valid: [
'+353871234567',
'353831234567',
'353851234567',
'353861234567',
'353871234567',
'353881234567',
'353891234567',
'0871234567',
'0851234567',
],
invalid: [
'999',
'+353341234567',
'+33589484858',
'353841234567',
'353811234567',
],
},
{
locale: 'en-KE',
valid: [
Expand Down
1 change: 1 addition & 0 deletions validator.js
Expand Up @@ -1383,6 +1383,7 @@ var phones = {
'en-GB': /^(\+?44|0)7\d{9}$/,
'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28)\d{7}$/,
'en-HK': /^(\+?852\-?)?[456789]\d{3}\-?\d{4}$/,
'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
'en-KE': /^(\+?254|0)?[7]\d{8}$/,
'en-MU': /^(\+?230|0)?\d{8}$/,
Expand Down
2 changes: 1 addition & 1 deletion validator.min.js

Large diffs are not rendered by default.

0 comments on commit b30c2ca

Please sign in to comment.