Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit45901ec

Browse files
authored
Merge pull request#1851 from validatorjs/chore/fix-merge-conflicts
chore: fix merge conflicts
2 parentsfc0fefc +83cb7f8 commit45901ec

File tree

3 files changed

+213
-1
lines changed

3 files changed

+213
-1
lines changed

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Validator | Description
146146
**isMagnetURI(str)** | check if the string is a[magnet uri format](https://en.wikipedia.org/wiki/Magnet_URI_scheme).
147147
**isMD5(str)** | check if the string is a MD5 hash.<br/><br/>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).
148148
**isMimeType(str)** | check if the string matches to a valid[MIME type](https://en.wikipedia.org/wiki/Media_type) format
149-
**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 `['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).<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`.
149+
**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 `['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).<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`.
150150
**isMongoId(str)** | check if the string is a valid hex-encoded representation of a[MongoDB ObjectId][mongoid].
151151
**isMultibyte(str)** | check if the string contains one or more multibyte chars.
152152
**isNumeric(str[, options])** | check if the string contains only numbers.<br/><br/>`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`.`).<br/><br/>`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']`.

‎src/lib/isMobilePhone.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const phones = {
1414
'ar-LY':/^((\+?218)|0)?(9[1-6]\d{7}|[1-8]\d{7,9})$/,
1515
'ar-MA':/^(?:(?:\+|00)212|0)[5-7]\d{8}$/,
1616
'ar-OM':/^((\+|00)968)?(9[1-9])\d{6}$/,
17+
'ar-PS':/^(\+?970|0)5[6|9](\d{7})$/,
1718
'ar-SA':/^(!?(\+?966)|0)?5\d{8}$/,
1819
'ar-SY':/^(!?(\+?963)|0)?9\d{8}$/,
1920
'ar-TN':/^(\+?216)?[2459]\d{7}$/,
@@ -29,19 +30,23 @@ const phones = {
2930
'de-AT':/^(\+43|0)\d{1,4}\d{3,12}$/,
3031
'de-CH':/^(\+41|0)([1-9])\d{1,9}$/,
3132
'de-LU':/^(\+352)?((6\d1)\d{6})$/,
33+
'dv-MV':/^(\+?960)?(7[2-9]|91|9[3-9])\d{7}$/,
3234
'el-GR':/^(\+?30|0)?(69\d{8})$/,
3335
'en-AU':/^(\+?61|0)4\d{8}$/,
3436
'en-BM':/^(\+?1)?441(((3|7)\d{6}$)|(5[0-3][0-9]\d{4}$)|(59\d{5}))/,
3537
'en-GB':/^(\+?44|0)7\d{9}$/,
3638
'en-GG':/^(\+?44|0)1481\d{6}$/,
3739
'en-GH':/^(\+233|0)(20|50|24|54|27|57|26|56|23|28|55|59)\d{7}$/,
40+
'en-GY':/^(\+592|0)6\d{6}$/,
3841
'en-HK':/^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/,
3942
'en-MO':/^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/,
4043
'en-IE':/^(\+?353|0)8[356789]\d{7}$/,
4144
'en-IN':/^(\+?91|0)?[6789]\d{9}$/,
4245
'en-KE':/^(\+?254|0)(7|1)\d{8}$/,
46+
'en-KI':/^((\+686|686)?)?()?((6|7)(2|3|8)[0-9]{6})$/,
4347
'en-MT':/^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/,
4448
'en-MU':/^(\+?230|0)?\d{8}$/,
49+
'en-NA':/^(\+?264|0)(6|8)\d{7}$/,
4550
'en-NG':/^(\+?234|0)?[789]\d{9}$/,
4651
'en-NZ':/^(\+?64|0)[28]\d{7,9}$/,
4752
'en-PK':/^((00|\+)?92|0)3[0-6]\d{8}$/,
@@ -55,6 +60,7 @@ const phones = {
5560
'en-ZA':/^(\+?27|0)\d{9}$/,
5661
'en-ZM':/^(\+?26)?09[567]\d{7}$/,
5762
'en-ZW':/^(\+263)[0-9]{9}$/,
63+
'en-BW':/^(\+?267)?(7[1-8]{1})\d{6}$/,
5864
'es-AR':/^\+?549(11|[2368]\d)\d{8}$/,
5965
'es-BO':/^(\+?591)?(6|7)\d{7}$/,
6066
'es-CO':/^(\+?57)?3(0(0|1|2|4|5)|1\d|2[0-4]|5(0|1))\d{7}$/,
@@ -69,18 +75,21 @@ const phones = {
6975
'es-MX':/^(\+?52)?(1|01)?\d{10,11}$/,
7076
'es-PA':/^(\+?507)\d{7,8}$/,
7177
'es-PY':/^(\+?595|0)9[9876]\d{7}$/,
78+
'es-SV':/^(\+?503)?[67]\d{7}$/,
7279
'es-UY':/^(\+598|0)9[1-9][\d]{6}$/,
7380
'es-VE':/^(\+?58)?(2|4)\d{9}$/,
7481
'et-EE':/^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,
7582
'fa-IR':/^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,
7683
'fi-FI':/^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,
7784
'fj-FJ':/^(\+?679)?\s?\d{3}\s?\d{4}$/,
7885
'fo-FO':/^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
86+
'fr-BF':/^(\+226|0)[67]\d{7}$/,
7987
'fr-CM':/^(\+?237)6[0-9]{8}$/,
8088
'fr-FR':/^(\+?33|0)[67]\d{8}$/,
8189
'fr-GF':/^(\+?594|0|00594)[67]\d{8}$/,
8290
'fr-GP':/^(\+?590|0|00590)[67]\d{8}$/,
8391
'fr-MQ':/^(\+?596|0|00596)[67]\d{8}$/,
92+
'fr-PF':/^(\+?689)?8[789]\d{6}$/,
8493
'fr-RE':/^(\+?262|0|00262)[67]\d{8}$/,
8594
'he-IL':/^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,
8695
'hu-HU':/^(\+?36|06)(20|30|31|50|70)\d{7}$/,
@@ -116,6 +125,7 @@ const phones = {
116125
'tg-TJ':/^(\+?992)?[5][5]\d{7}$/,
117126
'th-TH':/^(\+66|66|0)\d{9}$/,
118127
'tr-TR':/^(\+?90|0)?5\d{9}$/,
128+
'tk-TM':/^(\+993|993|8)\d{8}$/,
119129
'uk-UA':/^(\+?38|8)?0\d{9}$/,
120130
'uz-UZ':/^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/,
121131
'vi-VN':/^((\+?84)|0)((3([2-9]))|(5([25689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/,

‎test/validators.js‎

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6027,6 +6027,26 @@ describe('Validators', () => {
60276027
'02122333',
60286028
],
60296029
},
6030+
{
6031+
locale:'ar-PS',
6032+
valid:[
6033+
'+970563459876',
6034+
'970592334218',
6035+
'0566372345',
6036+
'0598273583',
6037+
],
6038+
invalid:[
6039+
'+9759029487',
6040+
'97059123456789',
6041+
'598372348',
6042+
'97058aaaafjd',
6043+
'',
6044+
'05609123484',
6045+
'+97059',
6046+
'+970',
6047+
'97056',
6048+
],
6049+
},
60306050
{
60316051
locale:'ar-SY',
60326052
valid:[
@@ -6523,6 +6543,22 @@ describe('Validators', () => {
65236543
'+233292345671',
65246544
],
65256545
},
6546+
{
6547+
locale:'en-GY',
6548+
valid:[
6549+
'+5926121234',
6550+
'06121234',
6551+
'06726381',
6552+
'+5926726381',
6553+
],
6554+
invalid:[
6555+
'5926121234',
6556+
'6121234',
6557+
'+592 6121234',
6558+
'05926121234',
6559+
'+592-6121234',
6560+
],
6561+
},
65266562
{
65276563
locale:'en-HK',
65286564
valid:[
@@ -6608,6 +6644,22 @@ describe('Validators', () => {
66086644
'+254800723845',
66096645
],
66106646
},
6647+
{
6648+
locale:'en-KI',
6649+
valid:[
6650+
'+68673140000',
6651+
'68673059999',
6652+
'+68663000000',
6653+
'68663019999',
6654+
],
6655+
invalid:[
6656+
'+68653000000',
6657+
'68664019999',
6658+
'+68619019999',
6659+
'686123456789',
6660+
'+686733445',
6661+
],
6662+
},
66116663
{
66126664
locale:'en-MT',
66136665
valid:[
@@ -6733,6 +6785,31 @@ describe('Validators', () => {
67336785
'+3361245789',
67346786
],
67356787
},
6788+
{
6789+
locale:'fr-BF',
6790+
valid:[
6791+
'+22661245789',
6792+
'+22665903092',
6793+
'+22672457898',
6794+
'+22673572346',
6795+
'061245789',
6796+
'071245783',
6797+
],
6798+
invalid:[
6799+
'0612457892',
6800+
'06124578980',
6801+
'0112457898',
6802+
'0212457898',
6803+
'0312457898',
6804+
'0412457898',
6805+
'0512457898',
6806+
'0812457898',
6807+
'0912457898',
6808+
'+22762457898',
6809+
'+226724578980',
6810+
'+22634523',
6811+
],
6812+
},
67366813
{
67376814
locale:'fr-CA',
67386815
valid:['19876543210','8005552222','+15673628910'],
@@ -6844,6 +6921,28 @@ describe('Validators', () => {
68446921
'+26261245789',
68456922
],
68466923
},
6924+
{
6925+
locale:'fr-PF',
6926+
valid:[
6927+
'87123456',
6928+
'88123456',
6929+
'89123456',
6930+
'+68987123456',
6931+
'+68988123456',
6932+
'+68989123456',
6933+
'68987123456',
6934+
'68988123456',
6935+
'68989123456',
6936+
],
6937+
invalid:[
6938+
'7123456',
6939+
'86123456',
6940+
'87 12 34 56',
6941+
'definitely not a number',
6942+
'01+68988123456',
6943+
'6898912345',
6944+
],
6945+
},
68476946
{
68486947
locale:'ka-GE',
68496948
valid:[
@@ -7000,6 +7099,27 @@ describe('Validators', () => {
70007099
'66338855',
70017100
],
70027101
},
7102+
{
7103+
locale:['en-NA'],
7104+
valid:[
7105+
'+26466189012',
7106+
'+26461555804',
7107+
'+26461434221',
7108+
'+26487555169',
7109+
'+26481555663',
7110+
],
7111+
invalid:[
7112+
'12345',
7113+
'',
7114+
'Vml2YW11cyBmZXJtZtesting123',
7115+
'+2641234567890',
7116+
'+2641234567',
7117+
'+2648143422',
7118+
'+264981234',
7119+
'4736338855',
7120+
'66338855',
7121+
],
7122+
},
70037123
{
70047124
locale:'ru-RU',
70057125
valid:[
@@ -7456,6 +7576,30 @@ describe('Validators', () => {
74567576
'+591993546843',
74577577
],
74587578
},
7579+
{
7580+
locale:'es-SV',
7581+
valid:[
7582+
'62136634',
7583+
'50361366631',
7584+
'+50361366634',
7585+
'+50361367217',
7586+
'+50361367460',
7587+
'+50371367632',
7588+
'+50371367767',
7589+
'+50371368314',
7590+
],
7591+
invalid:[
7592+
'+5032136663',
7593+
'21346663',
7594+
'+50321366663',
7595+
'12345',
7596+
'El salvador',
7597+
'this should fail',
7598+
'+5032222',
7599+
'+503 1111 1111',
7600+
'00 +503 1234 5678',
7601+
],
7602+
},
74597603
{
74607604
locale:'es-UY',
74617605
valid:[
@@ -8101,6 +8245,22 @@ describe('Validators', () => {
81018245
'081234567891',
81028246
],
81038247
},
8248+
{
8249+
locale:'tk-TM',
8250+
valid:[
8251+
'+99312495154',
8252+
'99312130136',
8253+
'+99312918407',
8254+
'99312183399',
8255+
'812391717',
8256+
],
8257+
invalid:[
8258+
'12345',
8259+
'+99412495154',
8260+
'99412495154',
8261+
'998900066506',
8262+
],
8263+
},
81048264
{
81058265
locale:['en-ZA','be-BY'],
81068266
valid:[
@@ -8145,6 +8305,31 @@ describe('Validators', () => {
81458305
'23274560591 ',
81468306
],
81478307
},
8308+
{
8309+
locale:'en-BW',
8310+
valid:[
8311+
'+26772868545',
8312+
'+26776368790',
8313+
'+26774560512',
8314+
'26774560591',
8315+
'26778560512',
8316+
'74560512',
8317+
'76710284',
8318+
],
8319+
invalid:[
8320+
'0799375902',
8321+
'12345',
8322+
'+2670745605448',
8323+
'2670745605482',
8324+
'+26779685451',
8325+
'+26770685451',
8326+
'267074560',
8327+
'2670ab5608',
8328+
'+267074560',
8329+
'70560512',
8330+
'79710284',
8331+
],
8332+
},
81488333
{
81498334
locale:'az-AZ',
81508335
valid:[
@@ -8297,6 +8482,23 @@ describe('Validators', () => {
82978482
'66338855',
82988483
],
82998484
},
8485+
{
8486+
locale:'dv-MV',
8487+
valid:[
8488+
'+960973256874',
8489+
'781246378',
8490+
'+960766354789',
8491+
'+960912354789',
8492+
],
8493+
invalid:[
8494+
'+96059234567',
8495+
'+96045789',
8496+
'7812463784',
8497+
'+960706985478',
8498+
'+960926985478',
8499+
'NotANumber',
8500+
],
8501+
},
83008502
];
83018503

83028504
letallValid=[];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp