Skip to content

Commit a948fb3

Browse files
committed
validator (v7.2): update a bunch of locales
Locales added in v7.2: - any (validatorjs/validator.js#663) - en-KE (validatorjs/validator.js#673) - en-UG, en-RW, en-TZ (validatorjs/validator.js#676) Missing locales (but added in this commit): - da-DK (validatorjs/validator.js#601) - uk-UA (validatorjs/validator.js#585) - en-NG (validatorjs/validator.js#616) - en-PK (validatorjs/validator.js#630) - he-IL (validatorjs/validator.js#610) - ro-RO (validatorjs/validator.js#627) - zh-HK (validatorjs/validator.js#622) Non-existent locales: - fr-BE, nl-BE (validatorjs/validator.js#700)
1 parent caf5db5 commit a948fb3

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

types/validator/index.d.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Type definitions for validator.js v7.1
1+
// Type definitions for validator.js v7.2
22
// Project: https://github.com/chriso/validator.js
33
// Definitions by: tgfjt <https://github.com/tgfjt>
44
// Ilya Mochalov <https://github.com/chrootsu>
@@ -10,9 +10,9 @@
1010
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
1111

1212
declare namespace ValidatorJS {
13-
type AlphaLocale = "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" | "cs-CZ" | "de-DE" | "en-AU" | "en-GB" | "en-HK" | "en-IN" | "en-NZ" | "en-US" | "en-ZA" | "en-ZM" | "es-ES" | "fr-FR" | "hu-HU" | "nl-NL" | "pl-PL" | "pt-BR" | "pt-PT" | "ru-RU" | "sr-RS" | "sr-RS@latin" | "tr-TR";
14-
type AlphanumericLocale = "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" | "cs-CZ" | "de-DE" | "en-AU" | "en-GB" | "en-HK" | "en-IN" | "en-NZ" | "en-US" | "en-ZA" | "en-ZM" | "es-ES" | "fr-FR" | "fr-BE" | "hu-HU" | "nl-BE" | "nl-NL" | "pl-PL" | "pt-BR" | "pt-PT" | "ru-RU" | "sr-RS" | "sr-RS@latin" | "tr-TR";
15-
type MobilePhoneLocale = "ar-DZ" | "ar-SA" | "ar-SY" | "cs-CZ" | "de-DE" | "da-DK" | "el-GR" | "en-AU" | "en-GB" | "en-HK" | "en-IN" | "en-NZ" | "en-US" | "en-CA" | "en-ZA" | "en-ZM" | "es-ES" | "fa-IR" | "fi-FI" | "fr-FR" | "hu-HU" | "id-ID" | "it-IT" | "ja-JP" | "ko-KR" | "lt-LT" | "ms-MY" | "nb-NO" | "nn-NO" | "pl-PL" | "pt-PT" | "ru-RU" | "sr-RS" | "tr-TR" | "vi-VN" | "zh-CN" | "zh-TW" | "any";
13+
type AlphaLocale = "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" | "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" | "hu-HU" | "nl-NL" | "pl-PL" | "pt-BR" | "pt-PT" | "ru-RU" | "sr-RS" | "sr-RS@latin" | "tr-TR" | "uk-UA";
14+
type AlphanumericLocale = "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" | "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" | "hu-HU" | "nl-NL" | "pl-PL" | "pt-BR" | "pt-PT" | "ru-RU" | "sr-RS" | "sr-RS@latin" | "tr-TR" | "uk-UA";
15+
type MobilePhoneLocale = "ar-DZ" | "ar-SA" | "ar-SY" | "cs-CZ" | "de-DE" | "da-DK" | "el-GR" | "en-AU" | "en-GB" | "en-HK" | "en-IN" | "en-KE" | "en-NG" | "en-NZ" | "en-UG" | "en-RW" | "en-TZ" | "en-PK" | "en-US" | "en-CA" | "en-ZA" | "en-ZM" | "es-ES" | "fa-IR" | "fi-FI" | "fr-FR" | "he-IL" | "hu-HU" | "id-ID" | "it-IT" | "ja-JP" | "ko-KR" | "lt-LT" | "ms-MY" | "nb-NO" | "nn-NO" | "pl-PL" | "pt-PT" | "ro-RO" | "ru-RU" | "sr-RS" | "tr-TR" | "vi-VN" | "zh-CN" | "zh-HK" | "zh-TW" | "any";
1616
type PostalCodeLocale = "AT" | "AU" | "BE" | "CA" | "CH" | "CZ" | "DE" | "DK" | "DZ" | "ES" | "FI" | "FR" | "GB" | "GR" | "IL" | "IN" | "IS" | "IT" | "JP" | "KE" | "LI" | "MX" | "NL" | "NO" | "PL" | "PT" | "RO" | "RU" | "SA" | "SE" | "TW" | "US" | "ZA" | "ZM" | "any"
1717

1818
interface ValidatorStatic {
@@ -32,14 +32,14 @@ declare namespace ValidatorJS {
3232

3333
// check if the string contains only letters (a-zA-Z). Locale is one of ['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG',
3434
// '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',
35-
// 'cs-CZ', 'de-DE', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-FR', 'hu-HU',
36-
// 'nl-NL', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sr-RS', 'sr-RS@latin', 'tr-TR']) and defaults to en-US
35+
// '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',
36+
// 'hu-HU', 'nl-NL', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sr-RS', 'sr-RS@latin', 'tr-TR' 'uk-UA']) and defaults to en-US
3737
isAlpha(str: string, locale?: AlphaLocale): boolean;
3838

3939
// check if the string contains only letters and numbers. Locale is one of ['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG',
4040
// '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',
41-
// 'cs-CZ', 'de-DE', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-FR', 'hu-HU',
42-
// 'nl-NL', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sr-RS', 'sr-RS@latin', 'tr-TR']) and defaults to en-US
41+
// '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',
42+
// 'hu-HU', 'nl-NL', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sr-RS', 'sr-RS@latin', 'tr-TR', 'uk-UA']) and defaults to en-US
4343
isAlphanumeric(str: string, locale?: AlphanumericLocale): boolean;
4444

4545
// check if the string contains ASCII chars only.
@@ -138,9 +138,10 @@ declare namespace ValidatorJS {
138138

139139
// check if the string is a mobile phone number, (locale is one of
140140
// ['ar-DZ', 'ar-SA', 'ar-SY', 'cs-CZ', 'de-DE', 'da-DK', 'el-GR', 'en-AU', 'en-GB', 'en-HK',
141-
// 'en-IN', 'en-NZ', 'en-US', 'en-CA', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fi-FI', 'fr-FR',
142-
// 'hu-HU', 'id-ID', 'it-IT', 'ja-JP', 'ko-KR', lt-LT', 'ms-MY', 'nb-NO', 'nn-NO', 'pl-PL',
143-
// 'pt-PT', 'ru-RU', 'sr-RS', 'tr-TR', 'vi-VN', 'zh-CN', 'zh-TW']).
141+
// 'en-IN', 'en-KE', 'en-NG', 'en-NZ', 'en-UG', 'en-RW', 'en-TZ', 'en-PK', 'en-US', 'en-CA',
142+
// 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fi-FI', 'fr-FR', 'he-IL', 'hu-HU', 'id-ID', 'it-IT',
143+
// 'ja-JP', 'ko-KR', lt-LT', 'ms-MY', 'nb-NO', 'nn-NO', 'pl-PL', 'pt-PT', 'ro-RO', 'ru-RU',
144+
// 'sr-RS', 'tr-TR', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-TW']).
144145
isMobilePhone(str: string, locale: MobilePhoneLocale): boolean;
145146

146147
// check if the string is a valid hex-encoded representation of a MongoDB ObjectId
@@ -157,8 +158,8 @@ declare namespace ValidatorJS {
157158
isNumeric(str: string): boolean;
158159

159160
// check if the string is a postal code, (locale is one of
160-
// [ 'AT', 'AU', 'BE', 'CA', 'CH', 'CZ', 'DE', 'DK', 'DZ', 'ES', 'FI', 'FR', 'GB', 'GR', 'IL',
161-
// 'IN', 'IS', 'IT', 'JP', 'KE', 'LI', 'MX', 'NL', 'NO', 'PL', 'PT', 'RO', 'RU', 'SA', 'SE',
161+
// [ 'AT', 'AU', 'BE', 'CA', 'CH', 'CZ', 'DE', 'DK', 'DZ', 'ES', 'FI', 'FR', 'GB', 'GR', 'IL',
162+
// 'IN', 'IS', 'IT', 'JP', 'KE', 'LI', 'MX', 'NL', 'NO', 'PL', 'PT', 'RO', 'RU', 'SA', 'SE',
162163
// 'TW', 'US', 'ZA', 'ZM' ]) OR 'any'. If 'any' is used, function will check if any of the
163164
// locales match).
164165
isPostalCode(str: string, locale: PostalCodeLocale): boolean;

types/validator/validator-tests.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ let any: any;
293293
result = validator.isAlpha('sample', 'ar-TN');
294294
result = validator.isAlpha('sample', 'ar-YE');
295295
result = validator.isAlpha('sample', 'cs-CZ');
296+
result = validator.isAlpha('sample', 'da-DK');
296297
result = validator.isAlpha('sample', 'de-DE');
297298
result = validator.isAlpha('sample', 'en-AU');
298299
result = validator.isAlpha('sample', 'en-GB');
@@ -313,6 +314,7 @@ let any: any;
313314
result = validator.isAlpha('sample', 'sr-RS');
314315
result = validator.isAlpha('sample', 'sr-RS@latin');
315316
result = validator.isAlpha('sample', 'tr-TR');
317+
result = validator.isAlpha('sample', 'uk-UA');
316318

317319
result = validator.isAlphanumeric('sample', 'ar');
318320
result = validator.isAlphanumeric('sample', 'ar-AE');
@@ -333,6 +335,7 @@ let any: any;
333335
result = validator.isAlphanumeric('sample', 'ar-TN');
334336
result = validator.isAlphanumeric('sample', 'ar-YE');
335337
result = validator.isAlphanumeric('sample', 'cs-CZ');
338+
result = validator.isAlphanumeric('sample', 'da-DK');
336339
result = validator.isAlphanumeric('sample', 'de-DE');
337340
result = validator.isAlphanumeric('sample', 'en-AU');
338341
result = validator.isAlphanumeric('sample', 'en-GB');
@@ -344,9 +347,7 @@ let any: any;
344347
result = validator.isAlphanumeric('sample', 'en-ZM');
345348
result = validator.isAlphanumeric('sample', 'es-ES');
346349
result = validator.isAlphanumeric('sample', 'fr-FR');
347-
result = validator.isAlphanumeric('sample', 'fr-BE');
348350
result = validator.isAlphanumeric('sample', 'hu-HU');
349-
result = validator.isAlphanumeric('sample', 'nl-BE');
350351
result = validator.isAlphanumeric('sample', 'nl-NL');
351352
result = validator.isAlphanumeric('sample', 'pl-PL');
352353
result = validator.isAlphanumeric('sample', 'pt-BR');
@@ -355,6 +356,7 @@ let any: any;
355356
result = validator.isAlphanumeric('sample', 'sr-RS');
356357
result = validator.isAlphanumeric('sample', 'sr-RS@latin');
357358
result = validator.isAlphanumeric('sample', 'tr-TR');
359+
result = validator.isAlphanumeric('sample', 'uk-UA');
358360

359361
result = validator.isAscii('sample');
360362

@@ -444,7 +446,13 @@ let any: any;
444446
result = validator.isMobilePhone('sample', 'en-GB');
445447
result = validator.isMobilePhone('sample', 'en-HK');
446448
result = validator.isMobilePhone('sample', 'en-IN');
449+
result = validator.isMobilePhone('sample', 'en-KE');
450+
result = validator.isMobilePhone('sample', 'en-NG');
447451
result = validator.isMobilePhone('sample', 'en-NZ');
452+
result = validator.isMobilePhone('sample', 'en-UG');
453+
result = validator.isMobilePhone('sample', 'en-RW');
454+
result = validator.isMobilePhone('sample', 'en-TZ');
455+
result = validator.isMobilePhone('sample', 'en-PK');
448456
result = validator.isMobilePhone('sample', 'en-US');
449457
result = validator.isMobilePhone('sample', 'en-CA');
450458
result = validator.isMobilePhone('sample', 'en-ZA');
@@ -453,6 +461,7 @@ let any: any;
453461
result = validator.isMobilePhone('sample', 'fa-IR');
454462
result = validator.isMobilePhone('sample', 'fi-FI');
455463
result = validator.isMobilePhone('sample', 'fr-FR');
464+
result = validator.isMobilePhone('sample', 'he-IL');
456465
result = validator.isMobilePhone('sample', 'hu-HU');
457466
result = validator.isMobilePhone('sample', 'id-ID');
458467
result = validator.isMobilePhone('sample', 'it-IT');
@@ -464,12 +473,15 @@ let any: any;
464473
result = validator.isMobilePhone('sample', 'nn-NO');
465474
result = validator.isMobilePhone('sample', 'pl-PL');
466475
result = validator.isMobilePhone('sample', 'pt-PT');
476+
result = validator.isMobilePhone('sample', 'ro-RO');
467477
result = validator.isMobilePhone('sample', 'ru-RU');
468478
result = validator.isMobilePhone('sample', 'sr-RS');
469479
result = validator.isMobilePhone('sample', 'tr-TR');
470480
result = validator.isMobilePhone('sample', 'vi-VN');
471481
result = validator.isMobilePhone('sample', 'zh-CN');
482+
result = validator.isMobilePhone('sample', 'zh-HK');
472483
result = validator.isMobilePhone('sample', 'zh-TW');
484+
result = validator.isMobilePhone('sample', 'any');
473485

474486
result = validator.isMongoId('sample');
475487

0 commit comments

Comments
 (0)