From a948fb3eb7bc6b3605efd87e9d31c3c078989fe3 Mon Sep 17 00:00:00 2001 From: Naoto Yokoyama Date: Tue, 20 Feb 2018 20:57:38 +0900 Subject: [PATCH] validator (v7.2): update a bunch of locales Locales added in v7.2: - any (https://github.com/chriso/validator.js/pull/663) - en-KE (https://github.com/chriso/validator.js/pull/673) - en-UG, en-RW, en-TZ (https://github.com/chriso/validator.js/pull/676) Missing locales (but added in this commit): - da-DK (https://github.com/chriso/validator.js/pull/601) - uk-UA (https://github.com/chriso/validator.js/pull/585) - en-NG (https://github.com/chriso/validator.js/pull/616) - en-PK (https://github.com/chriso/validator.js/pull/630) - he-IL (https://github.com/chriso/validator.js/pull/610) - ro-RO (https://github.com/chriso/validator.js/pull/627) - zh-HK (https://github.com/chriso/validator.js/pull/622) Non-existent locales: - fr-BE, nl-BE (https://github.com/chriso/validator.js/pull/700) --- types/validator/index.d.ts | 27 ++++++++++++++------------- types/validator/validator-tests.ts | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/types/validator/index.d.ts b/types/validator/index.d.ts index 22fe9517887f34..bfb1e5d4ad9e64 100644 --- a/types/validator/index.d.ts +++ b/types/validator/index.d.ts @@ -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 // Ilya Mochalov @@ -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 { @@ -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. @@ -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 @@ -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; diff --git a/types/validator/validator-tests.ts b/types/validator/validator-tests.ts index 76d08c1c6c169e..b6d44b04bf18fa 100644 --- a/types/validator/validator-tests.ts +++ b/types/validator/validator-tests.ts @@ -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'); @@ -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'); @@ -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'); @@ -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'); @@ -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'); @@ -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'); @@ -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'); @@ -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');