From 5c2d69e4699693f10d53e74c8958b2fbe3af0a64 Mon Sep 17 00:00:00 2001 From: ZeeMangena Date: Sat, 23 Oct 2021 21:53:46 +0200 Subject: [PATCH 01/11] feat(isMobilePhone): regex for Burkina Faso fr-BF and Namibia en-NA locales chore: squashed commits from #1834 feat(isMobilePhone): regex for Namibia locale fix(isMobilePhone): removing telephone validation fix(isMobliePhone): regex now validates as intended fix(isMobilePhone): requiring phone number prefixes in validation feat(isMobilePhone): regex for Burkina Faso locale fix(isMobilePhone): removing code intended for a different branch fix(isMobilePhone): Making plus sign optional feat(isMobilePhone): regex for Burkina Faso locale --- src/lib/isMobilePhone.js | 2 ++ test/validators.js | 46 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index 9f24bb916..6d5a3eb13 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -42,6 +42,7 @@ const phones = { 'en-KE': /^(\+?254|0)(7|1)\d{8}$/, 'en-MT': /^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/, 'en-MU': /^(\+?230|0)?\d{8}$/, + 'en-NA': /^(\+?264|0)(6|8)\d{7}$/, 'en-NG': /^(\+?234|0)?[789]\d{9}$/, 'en-NZ': /^(\+?64|0)[28]\d{7,9}$/, 'en-PK': /^((00|\+)?92|0)3[0-6]\d{8}$/, @@ -76,6 +77,7 @@ const phones = { 'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/, 'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/, 'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/, + 'fr-BF': /^(\+226|0)[67]\d{7}$/, 'fr-CM': /^(\+?237)6[0-9]{8}$/, 'fr-FR': /^(\+?33|0)[67]\d{8}$/, 'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/, diff --git a/test/validators.js b/test/validators.js index 9faf73d56..18583a07e 100644 --- a/test/validators.js +++ b/test/validators.js @@ -6733,6 +6733,31 @@ describe('Validators', () => { '+3361245789', ], }, + { + locale: 'fr-BF', + valid: [ + '+22661245789', + '+22665903092', + '+22672457898', + '+22673572346', + '061245789', + '071245783', + ], + invalid: [ + '0612457892', + '06124578980', + '0112457898', + '0212457898', + '0312457898', + '0412457898', + '0512457898', + '0812457898', + '0912457898', + '+22762457898', + '+226724578980', + '+22634523', + ], + }, { locale: 'fr-CA', valid: ['19876543210', '8005552222', '+15673628910'], @@ -7000,6 +7025,27 @@ describe('Validators', () => { '66338855', ], }, + { + locale: ['en-NA'], + valid: [ + '+26466189012', + '+26461555804', + '+26461434221', + '+26487555169', + '+26481555663', + ], + invalid: [ + '12345', + '', + 'Vml2YW11cyBmZXJtZtesting123', + '+2641234567890', + '+2641234567', + '+2648143422', + '+264981234', + '4736338855', + '66338855', + ], + }, { locale: 'ru-RU', valid: [ From c96d8059857af2e51a943197bd16b3e88e7efdcc Mon Sep 17 00:00:00 2001 From: Prajwal Raj Basnet Date: Tue, 26 Oct 2021 00:32:37 +0545 Subject: [PATCH 02/11] feat(isMobilePhone): add Maldives dv-MV locale chore: squashed #1829 Add locale for Maldives in mobile phone validator Add tests for mobile numbers validation of maldives locale i.e. dv-MV Update readme to add Maldives locale (dv-MV) in isMobilePhone documentation --- src/lib/isMobilePhone.js | 1 + test/validators.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index 6d5a3eb13..d60b3ce8b 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -29,6 +29,7 @@ const phones = { 'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/, 'de-CH': /^(\+41|0)([1-9])\d{1,9}$/, 'de-LU': /^(\+352)?((6\d1)\d{6})$/, + 'dv-MV': /^(\+?960)?(7[2-9]|91|9[3-9])\d{7}$/, 'el-GR': /^(\+?30|0)?(69\d{8})$/, 'en-AU': /^(\+?61|0)4\d{8}$/, 'en-BM': /^(\+?1)?441(((3|7)\d{6}$)|(5[0-3][0-9]\d{4}$)|(59\d{5}))/, diff --git a/test/validators.js b/test/validators.js index 18583a07e..74289e072 100644 --- a/test/validators.js +++ b/test/validators.js @@ -8343,6 +8343,23 @@ describe('Validators', () => { '66338855', ], }, + { + locale: 'dv-MV', + valid: [ + '+960973256874', + '781246378', + '+960766354789', + '+960912354789', + ], + invalid: [ + '+96059234567', + '+96045789', + '7812463784', + '+960706985478', + '+960926985478', + 'NotANumber', + ], + }, ]; let allValid = []; From ed601236d64fb00934ac9bbb1dc5102f8281dc20 Mon Sep 17 00:00:00 2001 From: Magnus Sustad <56775490+mgnss@users.noreply.github.com> Date: Sun, 31 Oct 2021 06:17:25 +0100 Subject: [PATCH 03/11] feat(isMobilePhone): add Tajikistan tg-TJ locale (#1846) --- test/validators.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/validators.js b/test/validators.js index 74289e072..df733845a 100644 --- a/test/validators.js +++ b/test/validators.js @@ -8360,6 +8360,27 @@ describe('Validators', () => { 'NotANumber', ], }, + { + locale: ['tg-TJ'], + valid: [ + '+992553388551', + '+992553322551', + '992553388551', + '992553322551', + ], + invalid: [ + '12345', + '', + 'Vml2YW11cyBmZXJtZtesting123', + '+995563388559', + '+9955633559', + '19676338855', + '+992263388505', + '9923633885', + '99255363885', + '66338855', + ], + }, ]; let allValid = []; From 8627e4815bcbbab7474ce23ae1c2599b3dba5462 Mon Sep 17 00:00:00 2001 From: Chris Tanner Date: Fri, 22 Oct 2021 13:45:03 -0400 Subject: [PATCH 04/11] feat(isMobilePhone): add Kiribati en-KI locale [chore] squashed from #1820 Clean up validator and add trailing comma --- src/lib/isMobilePhone.js | 1 + test/validators.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index d60b3ce8b..70b032cf8 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -41,6 +41,7 @@ const phones = { 'en-IE': /^(\+?353|0)8[356789]\d{7}$/, 'en-IN': /^(\+?91|0)?[6789]\d{9}$/, 'en-KE': /^(\+?254|0)(7|1)\d{8}$/, + 'en-KI': /^((\+686|686)?)?( )?((6|7)(2|3|8)[0-9]{6})$/, 'en-MT': /^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/, 'en-MU': /^(\+?230|0)?\d{8}$/, 'en-NA': /^(\+?264|0)(6|8)\d{7}$/, diff --git a/test/validators.js b/test/validators.js index df733845a..e3c69f0a0 100644 --- a/test/validators.js +++ b/test/validators.js @@ -6608,6 +6608,22 @@ describe('Validators', () => { '+254800723845', ], }, + { + locale: 'en-KI', + valid: [ + '+68673140000', + '68673059999', + '+68663000000', + '68663019999', + ], + invalid: [ + '+68653000000', + '68664019999', + '+68619019999', + '686123456789', + '+686733445', + ], + }, { locale: 'en-MT', valid: [ From f7ff349b0c0429a2c41cc18bc86fc85e9224ab4d Mon Sep 17 00:00:00 2001 From: Angel Mendez Date: Sat, 16 Oct 2021 11:35:42 -0500 Subject: [PATCH 05/11] feat(isMobilePhone): add Frech Polynesia fr-PF locale Create validation for frech polynesia mobile phones according to wikipedia: https://en.wikipedia.org/wiki/Telephone_numbers_in_French_Polynesia#Mobile --- src/lib/isMobilePhone.js | 1 + test/validators.js | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index 70b032cf8..404d9b02c 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -85,6 +85,7 @@ const phones = { '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-PF': /^(\+?689)?8[789]\d{6}$/, 'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/, 'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/, 'hu-HU': /^(\+?36|06)(20|30|31|50|70)\d{7}$/, diff --git a/test/validators.js b/test/validators.js index e3c69f0a0..8b12c03df 100644 --- a/test/validators.js +++ b/test/validators.js @@ -6885,6 +6885,28 @@ describe('Validators', () => { '+26261245789', ], }, + { + locale: 'fr-PF', + valid: [ + '87123456', + '88123456', + '89123456', + '+68987123456', + '+68988123456', + '+68989123456', + '68987123456', + '68988123456', + '68989123456', + ], + invalid: [ + '7123456', + '86123456', + '87 12 34 56', + 'definitely not a number', + '01+68988123456', + '6898912345', + ], + }, { locale: 'ka-GE', valid: [ From 0e5d5d4216885a4aa03a88c3c462e8a96110c378 Mon Sep 17 00:00:00 2001 From: Maximilian Krause Date: Tue, 12 Oct 2021 23:18:02 +0200 Subject: [PATCH 06/11] feat(isMobilePhone): add Guyana en-GY locale [chore] fixed merge conflicts in #1784 feat: (isMobilePhone) Add Guyana mobile phone validation Fix linter errors --- src/lib/isMobilePhone.js | 1 + test/validators.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index 404d9b02c..690075838 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -36,6 +36,7 @@ const phones = { 'en-GB': /^(\+?44|0)7\d{9}$/, 'en-GG': /^(\+?44|0)1481\d{6}$/, 'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28|55|59)\d{7}$/, + 'en-GY': /^(\+592|0)6\d{6}$/, 'en-HK': /^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/, 'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/, 'en-IE': /^(\+?353|0)8[356789]\d{7}$/, diff --git a/test/validators.js b/test/validators.js index 8b12c03df..76de75bd5 100644 --- a/test/validators.js +++ b/test/validators.js @@ -6523,6 +6523,22 @@ describe('Validators', () => { '+233292345671', ], }, + { + locale: 'en-GY', + valid: [ + '+5926121234', + '06121234', + '06726381', + '+5926726381', + ], + invalid: [ + '5926121234', + '6121234', + '+592 6121234', + '05926121234', + '+592-6121234', + ], + }, { locale: 'en-HK', valid: [ From 26605f9881495a0b6774dcd51833f566c0d6b794 Mon Sep 17 00:00:00 2001 From: Husan Eshonqulov <75156942+Husan-Eshonqulov@users.noreply.github.com> Date: Tue, 12 Oct 2021 22:41:24 +0500 Subject: [PATCH 07/11] feat(isMobilePhone): add Turkmenistan tk-TM squashed commits and resolved merge conflict for #1780 Add Turkmenistan validation regax Update README.md to include Turkmenistan (tk-Tm) Add test cases for tk-TM add missing comma for isMobilePhone.js add missing commas for test/validators.js --- src/lib/isMobilePhone.js | 1 + test/validators.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index 690075838..2e599de5a 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -122,6 +122,7 @@ const phones = { 'tg-TJ': /^(\+?992)?[5][5]\d{7}$/, 'th-TH': /^(\+66|66|0)\d{9}$/, 'tr-TR': /^(\+?90|0)?5\d{9}$/, + 'tk-TM': /^(\+993|993|8)\d{8}$/, 'uk-UA': /^(\+?38|8)?0\d{9}$/, 'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/, 'vi-VN': /^((\+?84)|0)((3([2-9]))|(5([25689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/, diff --git a/test/validators.js b/test/validators.js index 76de75bd5..9be3c840c 100644 --- a/test/validators.js +++ b/test/validators.js @@ -8201,6 +8201,22 @@ describe('Validators', () => { '081234567891', ], }, + { + locale: 'tk-TM', + valid: [ + '+99312495154', + '99312130136', + '+99312918407', + '99312183399', + '812391717', + ], + invalid: [ + '12345', + '+99412495154', + '99412495154', + '998900066506', + ], + }, { locale: ['en-ZA', 'be-BY'], valid: [ From a3faa8392783aed01d709e4e786ad35e32f743ef Mon Sep 17 00:00:00 2001 From: Megan Date: Sun, 10 Oct 2021 13:47:04 -0500 Subject: [PATCH 08/11] feat(isMobilePhone): add Botswana en-BW locale Added new condition for Botswana New regex for Botswana numbers Phone number information was found from the following sources: - https://www.howtocallabroad.com/botswana/ - https://countrycode.org/botswana Updated README.md to include en-BW Included the new case for Botswana (en-BW) Added test cases for isMobilePhone en-BW Added some test cases to check length for the phone number & area code pattern. Changed regex for BW Fixed the pattern for Botswana mobile phone numbers and edited the test cases. I followed the convention from Table 8 of the national numbering plan document and the mobile number pattern on the Wiki page. Update validators.js Oops! Looks like the file didn't update with some of my modified test cases - my apologies! --- src/lib/isMobilePhone.js | 1 + test/validators.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index 2e599de5a..ef5584934 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -59,6 +59,7 @@ const phones = { 'en-ZA': /^(\+?27|0)\d{9}$/, 'en-ZM': /^(\+?26)?09[567]\d{7}$/, 'en-ZW': /^(\+263)[0-9]{9}$/, + 'en-BW': /^(\+?267)?(7[1-8]{1})\d{6}$/, 'es-AR': /^\+?549(11|[2368]\d)\d{8}$/, 'es-BO': /^(\+?591)?(6|7)\d{7}$/, 'es-CO': /^(\+?57)?3(0(0|1|2|4|5)|1\d|2[0-4]|5(0|1))\d{7}$/, diff --git a/test/validators.js b/test/validators.js index 9be3c840c..da36a29b1 100644 --- a/test/validators.js +++ b/test/validators.js @@ -8261,6 +8261,31 @@ describe('Validators', () => { '23274560591 ', ], }, + { + locale: 'en-BW', + valid: [ + '+26772868545', + '+26776368790', + '+26774560512', + '26774560591', + '26778560512', + '74560512', + '76710284', + ], + invalid: [ + '0799375902', + '12345', + '+2670745605448', + '2670745605482', + '+26779685451', + '+26770685451', + '267074560', + '2670ab5608', + '+267074560', + '70560512', + '79710284', + ], + }, { locale: 'az-AZ', valid: [ From 5b067037996768f032facd5f2aeb89bb20188aa3 Mon Sep 17 00:00:00 2001 From: Brendan C <30474072+brendan-c@users.noreply.github.com> Date: Sat, 9 Oct 2021 18:12:16 -0400 Subject: [PATCH 09/11] feat(isMobilePhone): add Palestine ar-PS locale Add isMobilePhone test for ar-PS Add ar-PS to isMobilePhone readme Correct ar-PS validation Update ar-PS isMobible tests --- src/lib/isMobilePhone.js | 1 + test/validators.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index ef5584934..f5a8ffa6b 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -14,6 +14,7 @@ const phones = { 'ar-LY': /^((\+?218)|0)?(9[1-6]\d{7}|[1-8]\d{7,9})$/, 'ar-MA': /^(?:(?:\+|00)212|0)[5-7]\d{8}$/, 'ar-OM': /^((\+|00)968)?(9[1-9])\d{6}$/, + 'ar-PS': /^(\+?970|0)5[6|9](\d{7})$/, 'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/, 'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/, 'ar-TN': /^(\+?216)?[2459]\d{7}$/, diff --git a/test/validators.js b/test/validators.js index da36a29b1..32bb79974 100644 --- a/test/validators.js +++ b/test/validators.js @@ -6027,6 +6027,26 @@ describe('Validators', () => { '02122333', ], }, + { + locale: 'ar-PS', + valid: [ + '+970563459876', + '970592334218', + '0566372345', + '0598273583', + ], + invalid: [ + '+9759029487', + '97059123456789', + '598372348', + '97058aaaafjd', + '', + '05609123484', + '+97059', + '+970', + '97056', + ], + }, { locale: 'ar-SY', valid: [ From f17e220b1d8788549d5f9cb80662d001bad7fdbf Mon Sep 17 00:00:00 2001 From: Angel Mendez Date: Sat, 9 Oct 2021 15:03:28 -0500 Subject: [PATCH 10/11] feat(isMobilePhone): add El Salvador es-SV locale * Solve issue with wrong validation on El Salvador mobile phones * update tests accordingly in order to define the right regEx, the following site was consulted. https://www.siget.gob.sv/guia-de-servicios/consulta-el-plan-de-numeracion/numeros-moviles/ --- src/lib/isMobilePhone.js | 1 + test/validators.js | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index f5a8ffa6b..c70310ef7 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -75,6 +75,7 @@ const phones = { 'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/, 'es-PA': /^(\+?507)\d{7,8}$/, 'es-PY': /^(\+?595|0)9[9876]\d{7}$/, + 'es-SV': /^(\+?503)?[67]\d{7}$/, 'es-UY': /^(\+598|0)9[1-9][\d]{6}$/, 'es-VE': /^(\+?58)?(2|4)\d{9}$/, 'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/, diff --git a/test/validators.js b/test/validators.js index 32bb79974..14e3bfc93 100644 --- a/test/validators.js +++ b/test/validators.js @@ -7576,6 +7576,30 @@ describe('Validators', () => { '+591993546843', ], }, + { + locale: 'es-SV', + valid: [ + '62136634', + '50361366631', + '+50361366634', + '+50361367217', + '+50361367460', + '+50371367632', + '+50371367767', + '+50371368314', + ], + invalid: [ + '+5032136663', + '21346663', + '+50321366663', + '12345', + 'El salvador', + 'this should fail', + '+5032222', + '+503 1111 1111', + '00 +503 1234 5678', + ], + }, { locale: 'es-UY', valid: [ From 83cb7f8cca9e62c26852bc28ba600680751a36f1 Mon Sep 17 00:00:00 2001 From: Anthony Nandaa Date: Sun, 31 Oct 2021 15:00:36 +0300 Subject: [PATCH 11/11] chore: merge conflict clean-up --- README.md | 2 +- test/validators.js | 21 --------------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/README.md b/README.md index d074f8dab..2cf6505be 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ Validator | Description **isMagnetURI(str)** | check if the string is a [magnet uri format](https://en.wikipedia.org/wiki/Magnet_URI_scheme). **isMD5(str)** | check if the string is a MD5 hash.

Please note that you can also use the `isHash(str, 'md5')` function. Keep in mind that MD5 has some collision weaknesses compared to other algorithms (e.g., SHA). **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,

(locale is either an array of locales (e.g `['sk-SK', 'sr-RS']`) OR one of `['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-SA', 'ar-SY', 'ar-TN', 'az-AZ', 'az-LY', 'az-LB', 'bs-BA', 'be-BY', 'bg-BG', 'bn-BD', 'ca-AD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'de-CH', 'de-LU', 'el-GR', 'en-AU', 'en-BM', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-HK', 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-PH', 'en-RW', 'en-SG', 'en-SL', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'en-ZW', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-CU', 'es-DO', 'es-HN', 'es-PE', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-UY', 'es-VE', 'et-EE', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'ga-IE', 'he-IL', 'hu-HU', 'id-ID', 'it-IT', 'it-SM', 'ja-JP', 'ka-GE', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', ''mz-MZ', nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'pt-AO', 'ro-RO', 'ru-RU', 'si-LK' 'sl-SI', 'sk-SK', 'sq-AL', 'sr-RS', 'sv-SE', 'tg-TJ', 'th-TH', 'tr-TR', 'uk-UA', 'uz-UZ', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-TW', 'dz-BT']` OR defaults to 'any'. If 'any' or a falsey value is used, function will check if any of the locales match).

`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,

(locale is either an array of locales (e.g `['sk-SK', 'sr-RS']`) OR one of `['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-PS', 'ar-SA', 'ar-SY', 'ar-TN', 'az-AZ', 'az-LY', 'az-LB', 'bs-BA', 'be-BY', 'bg-BG', 'bn-BD', 'ca-AD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'de-CH', 'de-LU', 'dv-MV', 'el-GR', 'en-AU', 'en-BM', 'en-BW', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-GY', 'en-HK', 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-KI', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-PH', 'en-RW', 'en-SG', 'en-SL', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'en-ZW', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-CU', 'es-DO', 'es-HN', 'es-PE', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-SV', 'es-UY', 'es-VE', 'et-EE', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-BF', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-PF', 'fr-RE', 'ga-IE', 'he-IL', 'hu-HU', 'id-ID', 'it-IT', 'it-SM', 'ja-JP', 'ka-GE', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', ''mz-MZ', nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'pt-AO', 'ro-RO', 'ru-RU', 'si-LK' 'sl-SI', 'sk-SK', 'sq-AL', 'sr-RS', 'sv-SE', 'tg-TJ', 'th-TH', 'tk-TM', 'tr-TR', 'uk-UA', 'uz-UZ', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-TW', 'dz-BT']` OR defaults to 'any'. If 'any' or a falsey value is used, function will check if any of the locales match).

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

`options` is an object which defaults to `{no_symbols: false}` it also has locale as an option. If `no_symbols` is true, the validator will reject numeric strings that feature a symbol (e.g. `+`, `-`, or `.`).

`locale` determine the decimal separator and is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-FR', 'fr-CA', 'hu-HU', 'it-IT', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`. diff --git a/test/validators.js b/test/validators.js index 14e3bfc93..a4e00293b 100644 --- a/test/validators.js +++ b/test/validators.js @@ -8499,27 +8499,6 @@ describe('Validators', () => { 'NotANumber', ], }, - { - locale: ['tg-TJ'], - valid: [ - '+992553388551', - '+992553322551', - '992553388551', - '992553322551', - ], - invalid: [ - '12345', - '', - 'Vml2YW11cyBmZXJtZtesting123', - '+995563388559', - '+9955633559', - '19676338855', - '+992263388505', - '9923633885', - '99255363885', - '66338855', - ], - }, ]; let allValid = [];