Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up PR 886 #1060

Merged
merged 3 commits into from Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -121,7 +121,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-BH', '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-AT' 'de-DE', 'da-DK', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GH', 'en-HK', 'en-IE', 'en-IN', 'en-KE', 'en-MT', '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-PY', 'es-UY', 'et-EE', 'fa-IR', 'fi-FI', 'fj-FJ', 'fr-FR', 'he-IL', 'hu-HU', 'id-ID', 'it-IT', 'ja-JP', 'kk-KZ', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'nl-BE', 'nl-NL', '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-BH', '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', 'de-AT', 'da-DK', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GH', 'en-HK', 'en-IE', 'en-IN', 'en-KE', 'en-MT', '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-PY', 'es-UY', 'et-EE', 'fa-IR', 'fi-FI', 'fj-FJ', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'he-IL', 'hu-HU', 'id-ID', 'it-IT', 'ja-JP', 'kk-KZ', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'nl-BE', 'nl-NL', '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
4 changes: 4 additions & 0 deletions lib/isMobilePhone.js
Expand Up @@ -60,6 +60,10 @@ var phones = {
'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/,
'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
'fr-FR': /^(\+?33|0)[67]\d{8}$/,
'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/,
'fr-GP': /^(\+?590|0|00590)[67]\d{8}$/,
'fr-MQ': /^(\+?596|0|00596)[67]\d{8}$/,
'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/,
'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,
'hu-HU': /^(\+?36)(20|30|70)\d{7}$/,
'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
Expand Down
4 changes: 4 additions & 0 deletions src/lib/isMobilePhone.js
Expand Up @@ -50,6 +50,10 @@ const phones = {
'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/,
'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
'fr-FR': /^(\+?33|0)[67]\d{8}$/,
'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/,
'fr-GP': /^(\+?590|0|00590)[67]\d{8}$/,
'fr-MQ': /^(\+?596|0|00596)[67]\d{8}$/,
'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/,
'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,
'hu-HU': /^(\+?36)(20|30|70)\d{7}$/,
'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
Expand Down
100 changes: 100 additions & 0 deletions test/validators.js
Expand Up @@ -4117,6 +4117,106 @@ describe('Validators', () => {
'+3361245789',
],
},
{
locale: 'fr-GF',
valid: [
'0612457898',
'+594612457898',
'594612457898',
'0712457898',
'+594712457898',
'594712457898',
],
invalid: [
'061245789',
'06124578980',
'0112457898',
'0212457898',
'0312457898',
'0412457898',
'0512457898',
'0812457898',
'0912457898',
'+54612457898',
'+5946124578980',
'+59461245789',
],
},
{
locale: 'fr-GP',
valid: [
'0612457898',
'+590612457898',
'590612457898',
'0712457898',
'+590712457898',
'590712457898',
],
invalid: [
'061245789',
'06124578980',
'0112457898',
'0212457898',
'0312457898',
'0412457898',
'0512457898',
'0812457898',
'0912457898',
'+594612457898',
'+5906124578980',
'+59061245789',
],
},
{
locale: 'fr-MQ',
valid: [
'0612457898',
'+596612457898',
'596612457898',
'0712457898',
'+596712457898',
'596712457898',
],
invalid: [
'061245789',
'06124578980',
'0112457898',
'0212457898',
'0312457898',
'0412457898',
'0512457898',
'0812457898',
'0912457898',
'+594612457898',
'+5966124578980',
'+59661245789',
],
},
{
locale: 'fr-RE',
valid: [
'0612457898',
'+262612457898',
'262612457898',
'0712457898',
'+262712457898',
'262712457898',
],
invalid: [
'061245789',
'06124578980',
'0112457898',
'0212457898',
'0312457898',
'0412457898',
'0512457898',
'0812457898',
'0912457898',
'+264612457898',
'+2626124578980',
'+26261245789',
],
},
{
locale: 'el-GR',
valid: [
Expand Down
4 changes: 4 additions & 0 deletions validator.js
Expand Up @@ -1389,6 +1389,10 @@ var phones = {
'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/,
'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
'fr-FR': /^(\+?33|0)[67]\d{8}$/,
'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/,
'fr-GP': /^(\+?590|0|00590)[67]\d{8}$/,
'fr-MQ': /^(\+?596|0|00596)[67]\d{8}$/,
'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/,
'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,
'hu-HU': /^(\+?36)(20|30|70)\d{7}$/,
'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
Expand Down
2 changes: 1 addition & 1 deletion validator.min.js

Large diffs are not rendered by default.