Skip to content

Commit

Permalink
validator (v7.2): update a bunch of locales
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
builtinnya committed Feb 20, 2018
1 parent caf5db5 commit a948fb3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
27 changes: 14 additions & 13 deletions types/validator/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for validator.js v7.1
// Type definitions for validator.js v7.2
// Project: https://github.com/chriso/validator.js
// Definitions by: tgfjt <https://github.com/tgfjt>
// Ilya Mochalov <https://github.com/chrootsu>
Expand All @@ -10,9 +10,9 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

declare namespace ValidatorJS {
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";
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";
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";
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";
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";
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";
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"

interface ValidatorStatic {
Expand All @@ -32,14 +32,14 @@ declare namespace ValidatorJS {

// check if the string contains only letters (a-zA-Z). Locale 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',
// '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']) and defaults to en-US
// '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']) and defaults to en-US
isAlpha(str: string, locale?: AlphaLocale): boolean;

// check if the string contains only letters and numbers. Locale 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',
// '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']) and defaults to en-US
// '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']) and defaults to en-US
isAlphanumeric(str: string, locale?: AlphanumericLocale): boolean;

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

// check if the string is a mobile phone number, (locale is one of
// ['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']).
// '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']).
isMobilePhone(str: string, locale: MobilePhoneLocale): boolean;

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

// check if the string is a postal code, (locale is one of
// [ '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',
// [ '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' ]) OR 'any'. If 'any' is used, function will check if any of the
// locales match).
isPostalCode(str: string, locale: PostalCodeLocale): boolean;
Expand Down
16 changes: 14 additions & 2 deletions types/validator/validator-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ let any: any;
result = validator.isAlpha('sample', 'ar-TN');
result = validator.isAlpha('sample', 'ar-YE');
result = validator.isAlpha('sample', 'cs-CZ');
result = validator.isAlpha('sample', 'da-DK');
result = validator.isAlpha('sample', 'de-DE');
result = validator.isAlpha('sample', 'en-AU');
result = validator.isAlpha('sample', 'en-GB');
Expand All @@ -313,6 +314,7 @@ let any: any;
result = validator.isAlpha('sample', 'sr-RS');
result = validator.isAlpha('sample', 'sr-RS@latin');
result = validator.isAlpha('sample', 'tr-TR');
result = validator.isAlpha('sample', 'uk-UA');

result = validator.isAlphanumeric('sample', 'ar');
result = validator.isAlphanumeric('sample', 'ar-AE');
Expand All @@ -333,6 +335,7 @@ let any: any;
result = validator.isAlphanumeric('sample', 'ar-TN');
result = validator.isAlphanumeric('sample', 'ar-YE');
result = validator.isAlphanumeric('sample', 'cs-CZ');
result = validator.isAlphanumeric('sample', 'da-DK');
result = validator.isAlphanumeric('sample', 'de-DE');
result = validator.isAlphanumeric('sample', 'en-AU');
result = validator.isAlphanumeric('sample', 'en-GB');
Expand All @@ -344,9 +347,7 @@ let any: any;
result = validator.isAlphanumeric('sample', 'en-ZM');
result = validator.isAlphanumeric('sample', 'es-ES');
result = validator.isAlphanumeric('sample', 'fr-FR');
result = validator.isAlphanumeric('sample', 'fr-BE');
result = validator.isAlphanumeric('sample', 'hu-HU');
result = validator.isAlphanumeric('sample', 'nl-BE');
result = validator.isAlphanumeric('sample', 'nl-NL');
result = validator.isAlphanumeric('sample', 'pl-PL');
result = validator.isAlphanumeric('sample', 'pt-BR');
Expand All @@ -355,6 +356,7 @@ let any: any;
result = validator.isAlphanumeric('sample', 'sr-RS');
result = validator.isAlphanumeric('sample', 'sr-RS@latin');
result = validator.isAlphanumeric('sample', 'tr-TR');
result = validator.isAlphanumeric('sample', 'uk-UA');

result = validator.isAscii('sample');

Expand Down Expand Up @@ -444,7 +446,13 @@ let any: any;
result = validator.isMobilePhone('sample', 'en-GB');
result = validator.isMobilePhone('sample', 'en-HK');
result = validator.isMobilePhone('sample', 'en-IN');
result = validator.isMobilePhone('sample', 'en-KE');
result = validator.isMobilePhone('sample', 'en-NG');
result = validator.isMobilePhone('sample', 'en-NZ');
result = validator.isMobilePhone('sample', 'en-UG');
result = validator.isMobilePhone('sample', 'en-RW');
result = validator.isMobilePhone('sample', 'en-TZ');
result = validator.isMobilePhone('sample', 'en-PK');
result = validator.isMobilePhone('sample', 'en-US');
result = validator.isMobilePhone('sample', 'en-CA');
result = validator.isMobilePhone('sample', 'en-ZA');
Expand All @@ -453,6 +461,7 @@ let any: any;
result = validator.isMobilePhone('sample', 'fa-IR');
result = validator.isMobilePhone('sample', 'fi-FI');
result = validator.isMobilePhone('sample', 'fr-FR');
result = validator.isMobilePhone('sample', 'he-IL');
result = validator.isMobilePhone('sample', 'hu-HU');
result = validator.isMobilePhone('sample', 'id-ID');
result = validator.isMobilePhone('sample', 'it-IT');
Expand All @@ -464,12 +473,15 @@ let any: any;
result = validator.isMobilePhone('sample', 'nn-NO');
result = validator.isMobilePhone('sample', 'pl-PL');
result = validator.isMobilePhone('sample', 'pt-PT');
result = validator.isMobilePhone('sample', 'ro-RO');
result = validator.isMobilePhone('sample', 'ru-RU');
result = validator.isMobilePhone('sample', 'sr-RS');
result = validator.isMobilePhone('sample', 'tr-TR');
result = validator.isMobilePhone('sample', 'vi-VN');
result = validator.isMobilePhone('sample', 'zh-CN');
result = validator.isMobilePhone('sample', 'zh-HK');
result = validator.isMobilePhone('sample', 'zh-TW');
result = validator.isMobilePhone('sample', 'any');

result = validator.isMongoId('sample');

Expand Down

0 comments on commit a948fb3

Please sign in to comment.