diff --git a/README.md b/README.md
index 8ef42fd79..ac7dfcf02 100644
--- a/README.md
+++ b/README.md
@@ -119,7 +119,7 @@ Validator | Description
**isHexColor(str [, options])** | check if the string is a hexadecimal color.
`options` is an object that defaults to `{ require_hashtag: false }`.
Options:
`require_hashtag`: Enforce # prefix, default false.
**isHSL(str)** | check if the string is an HSL (hue, saturation, lightness, optional alpha) color based on [CSS Colors Level 4 specification][CSS Colors Level 4 Specification].
Comma-separated format supported. Space-separated format supported with the exception of a few edge cases (ex: `hsl(200grad+.1%62%/1)`).
**isIBAN(str, [, options])** | check if the string is an IBAN (International Bank Account Number).
`options` is an object which accepts two attributes: `whitelist`: where you can restrict IBAN codes you want to receive data from and `blacklist`: where you can remove some of the countries from the current list. For both you can use an array with the following values `['AD','AE','AL','AT','AZ','BA','BE','BG','BH','BR','BY','CH','CR','CY','CZ','DE','DK','DO','EE','EG','ES','FI','FO','FR','GB','GE','GI','GL','GR','GT','HR','HU','IE','IL','IQ','IR','IS','IT','JO','KW','KZ','LB','LC','LI','LT','LU','LV','MC','MD','ME','MK','MR','MT','MU','MZ','NL','NO','PK','PL','PS','PT','QA','RO','RS','SA','SC','SE','SI','SK','SM','SV','TL','TN','TR','UA','VA','VG','XK']`.
-**isIdentityCard(str [, locale])** | check if the string is a valid identity card code.
`locale` is one of `['LK', 'PL', 'ES', 'FI', 'IN', 'IT', 'IR', 'MZ', 'NO', 'TH', 'zh-TW', 'he-IL', 'ar-LY', 'ar-TN', 'zh-CN', 'zh-HK', 'PK']` OR `'any'`. If 'any' is used, function will check if any of the locales match.
Defaults to 'any'.
+**isIdentityCard(str [, locale])** | check if the string is a valid identity card code.
`locale` is one of `['LK', 'PL', 'ES', 'FI', 'IN', 'IT', 'IR', 'MZ', 'NO', 'TH', 'zh-TW', 'he-IL', 'ht-HT', 'ar-LY', 'ar-TN', 'zh-CN', 'zh-HK', 'PK']` OR `'any'`. If 'any' is used, function will check if any of the locales match.
Defaults to 'any'.
**isIMEI(str [, options]))** | check if the string is a valid [IMEI number][IMEI]. IMEI should be of format `###############` or `##-######-######-#`.
`options` is an object which can contain the keys `allow_hyphens`. Defaults to first format. If `allow_hyphens` is set to true, the validator will validate the second format.
**isIn(str, values)** | check if the string is in an array of allowed values.
**isInt(str [, options])** | check if the string is an integer.
`options` is an object which can contain the keys `min` and/or `max` to check the integer is within boundaries (e.g. `{ min: 10, max: 99 }`). `options` can also contain the key `allow_leading_zeroes`, which when set to false will disallow integer values with leading zeroes (e.g. `{ allow_leading_zeroes: false }`). Finally, `options` can contain the keys `gt` and/or `lt` which will enforce integers being greater than or less than, respectively, the value provided (e.g. `{gt: 1, lt: 4}` for a number between 1 and 4).
@@ -150,7 +150,7 @@ Validator | Description
**isMailtoURI(str, [, options])** | check if the string is a [Mailto URI format][Mailto URI Format].
`options` is an object of validating emails inside the URI (check `isEmail`s options for details).
**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][MIME 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-EH', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-PS', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'az-AZ', 'az-LB', 'az-LY', 'be-BY', 'bg-BG', 'bn-BD', 'bs-BA', 'ca-AD', 'cs-CZ', 'da-DK', 'de-AT', 'de-CH', 'de-DE', 'de-LU', 'dv-MV', 'dz-BT', 'el-CY', 'el-GR', 'en-AG', 'en-AI', 'en-AU', 'en-BM', 'en-BS', 'en-BW', 'en-CA', 'en-CM', 'en-GB', 'en-GG', 'en-GH', 'en-GY', 'en-HK', 'en-IE', 'en-IN', 'en-JM', 'en-KE', 'en-KI', 'en-KN', 'en-LS', 'en-MO', 'en-MT', 'en-MU', 'en-MW', 'en-NG', 'en-NZ', 'en-PG', 'en-PH', 'en-PK', 'en-RW', 'en-SG', 'en-SL', 'en-SS', 'en-TZ', 'en-UG', 'en-US', 'en-ZA', 'en-ZM', 'en-ZW', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-CU', 'es-DO', 'es-EC', 'es-ES', 'es-GT', 'es-HN', 'es-MX', 'es-NI', 'es-PA', 'es-PE', 'es-PY', 'es-SV', 'es-UY', 'es-VE', 'et-EE', 'fa-AF', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-BF', 'fr-BJ', 'fr-CD', 'fr-CF', 'fr-DJ', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-PF', 'fr-RE', 'fr-WF', 'ga-IE', 'he-IL', 'hu-HU', 'id-ID', 'ir-IR', 'it-IT', 'it-SM', 'ja-JP', 'ka-GE', 'kk-KZ', 'kl-GL', 'ko-KR', 'ky-KG', 'lt-LT', 'mg-MG', 'mn-MN', 'mk-MK', 'ms-MY', 'my-MM', 'mz-MZ', 'nb-NO', 'ne-NP', 'nl-AW', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-AO', 'pt-BR', 'pt-PT', 'ro-Md', 'ro-RO', 'ru-RU', 'si-LK', 'sk-SK', 'sl-SI', 'so-SO', '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']` 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-EH', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-OM', 'ar-PS', 'ar-QA', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'az-AZ', 'be-BY', 'bg-BG', 'bn-BD', 'bs-BA', 'ca-AD', 'cs-CZ', 'da-DK', 'de-AT', 'de-CH', 'de-DE', 'de-LU', 'dv-MV', 'dz-BT', 'el-CY', 'el-GR', 'en-AG', 'en-AI', 'en-AU', 'en-BM', 'en-BS', 'en-BW', 'en-CA', 'en-CM', 'en-GB', 'en-GG', 'en-GH', 'en-GY', 'en-HK', 'en-IE', 'en-IN', 'en-JM', 'en-KE', 'en-KI', 'en-KN', 'en-LS', 'en-MO', 'en-MT', 'en-MU', 'en-MW', 'en-NA', 'en-NG', 'en-NZ', 'en-PG', 'en-PH', 'en-PK', 'en-RW', 'en-SG', 'en-SL', 'en-SS', 'en-TZ', 'en-UG', 'en-US', 'en-ZA', 'en-ZM', 'en-ZW', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-CU', 'es-DO', 'es-EC', 'es-ES', 'es-GT', 'es-HN', 'es-MX', 'es-NI', 'es-PA', 'es-PE', 'es-PY', 'es-SV', 'es-UY', 'es-VE', 'et-EE', 'fa-AF', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-BF', 'fr-BJ', 'fr-CA', 'fr-CD', 'fr-CF', 'fr-CH', 'fr-CM', 'fr-DJ', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-PF', 'fr-RE', 'fr-WF', 'ga-IE', 'he-IL', 'ht-HT', 'hu-HU', 'id-ID', 'ir-IR', 'it-CH', 'it-IT', 'it-SM', 'ja-JP', 'ka-GE', 'kk-KZ', 'kl-GL', 'ko-KR', 'ky-KG', 'lt-LT', 'lv-LV', 'mg-MG', 'mk-MK', 'mn-MN', 'ms-MY', 'my-MM', 'mz-MZ', 'nb-NO', 'ne-NP', 'nl-AW', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-AO', 'pt-BR', 'pt-PT', 'ro-MD', 'ro-RO', 'ru-RU', 'si-LK', 'sk-SK', 'sl-SI', 'so-SO', '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']` 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` determines 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', 'eo', '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/src/lib/isCreditCard.js b/src/lib/isCreditCard.js
index 938679d39..5a5b34b17 100644
--- a/src/lib/isCreditCard.js
+++ b/src/lib/isCreditCard.js
@@ -6,7 +6,7 @@ const cards = {
dinersclub: /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
discover: /^6(?:011|5[0-9][0-9])[0-9]{12,15}$/,
jcb: /^(?:2131|1800|35\d{3})\d{11}$/,
- mastercard: /^5[1-5][0-9]{2}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$/, // /^[25][1-7][0-9]{14}$/;
+ mastercard: /^(?:5[1-5][0-9]{14}|(?:222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12})$/,
unionpay: /^(6[27][0-9]{14}|^(81[0-9]{14,17}))$/,
visa: /^(?:4[0-9]{12})(?:[0-9]{3,6})?$/,
};
diff --git a/src/lib/isISO6346.js b/src/lib/isISO6346.js
index 2c28c1123..cb6ac7b32 100644
--- a/src/lib/isISO6346.js
+++ b/src/lib/isISO6346.js
@@ -3,7 +3,7 @@ import assertString from './util/assertString';
// https://en.wikipedia.org/wiki/ISO_6346
// according to ISO6346 standard, checksum digit is mandatory for freight container but recommended
// for other container types (J and Z)
-const isISO6346Str = /^[A-Z]{3}(U[0-9]{7})|([J,Z][0-9]{6,7})$/;
+const isISO6346Str = /^[A-Z]{3}(U[0-9]{7}|[JZ][0-9]{6,7})$/;
const isDigit = /^[0-9]$/;
export function isISO6346(str) {
diff --git a/src/lib/isIdentityCard.js b/src/lib/isIdentityCard.js
index 7e20064e1..dd1ab16f4 100644
--- a/src/lib/isIdentityCard.js
+++ b/src/lib/isIdentityCard.js
@@ -227,6 +227,15 @@ const validators = {
return DNI.test(sanitized);
},
+ 'ht-HT': (str) => {
+ // Haiti National Identity Card (CIN - Carte d'Identité Nationale)
+ // Format: 1 letter followed by 10 digits (11 characters total)
+ const CIN = /^[A-Z]\d{10}$/;
+
+ const sanitized = str.trim().toUpperCase();
+
+ return CIN.test(sanitized);
+ },
'zh-CN': (str) => {
const provincesAndCities = [
'11', // 北京
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index 32379bde5..6f173b567 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -111,6 +111,7 @@ const phones = {
'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/,
'fr-WF': /^(\+681)?\d{6}$/,
'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,
+ 'ht-HT': /^(\+?509)?[2-4]\d{7}$/,
'hu-HU': /^(\+?36|06)(20|30|31|50|70)\d{7}$/,
'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
'ir-IR': /^(\+98|0)?9\d{9}$/,
@@ -154,7 +155,7 @@ const phones = {
'tr-TR': /^(\+?90|0)?5\d{9}$/,
'tk-TM': /^(\+993|993|8)\d{8}$/,
'uk-UA': /^(\+?38)?0(50|6[36-8]|7[357]|9[1-9])\d{7}$/,
- 'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/,
+ 'uz-UZ': /^(\+?998)?(33|6[125-79]|7[1-9]|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})$/,
'zh-CN': /^((\+|00)86)?(1[3-9]|9[28])\d{9}$/,
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/,
diff --git a/src/lib/isRgbColor.js b/src/lib/isRgbColor.js
index a672df279..c8272a05c 100644
--- a/src/lib/isRgbColor.js
+++ b/src/lib/isRgbColor.js
@@ -2,9 +2,9 @@
import assertString from './util/assertString';
const rgbColor = /^rgb\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){2}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\)$/;
-const rgbaColor = /^rgba\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){3}(0?\.\d\d?|1(\.0)?|0(\.0)?)\)$/;
+const rgbaColor = /^rgba\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){3}(0(\.\d+)?|1(\.0+)?|\.\d+)\)$/;
const rgbColorPercent = /^rgb\((([0-9]%|[1-9][0-9]%|100%),){2}([0-9]%|[1-9][0-9]%|100%)\)$/;
-const rgbaColorPercent = /^rgba\((([0-9]%|[1-9][0-9]%|100%),){3}(0?\.\d\d?|1(\.0)?|0(\.0)?)\)$/;
+const rgbaColorPercent = /^rgba\((([0-9]%|[1-9][0-9]%|100%),){3}(0(\.\d+)?|1(\.0+)?|\.\d+)\)$/;
const startsWithRgb = /^rgba?/;
export default function isRgbColor(str, options) {
diff --git a/src/lib/normalizeEmail.js b/src/lib/normalizeEmail.js
index ceb252f34..f4349ac1e 100644
--- a/src/lib/normalizeEmail.js
+++ b/src/lib/normalizeEmail.js
@@ -14,7 +14,7 @@ const default_normalize_email_options = {
gmail_remove_dots: true,
// Removes the subaddress (e.g. "+foo") from the email address
gmail_remove_subaddress: true,
- // Conversts the googlemail.com domain to gmail.com
+ // Converts the googlemail.com domain to gmail.com
gmail_convert_googlemaildotcom: true,
// The following conversions are specific to Outlook.com / Windows Live / Hotmail
diff --git a/test/validators.test.js b/test/validators.test.js
index 9c867efae..e682f8596 100644
--- a/test/validators.test.js
+++ b/test/validators.test.js
@@ -5122,6 +5122,10 @@ describe('Validators', () => {
'rgb(5%,5%,5%)',
'rgba(5%,5%,5%,.3)',
'rgba(5%,5%,5%,.32)',
+ 'rgba(255,255,255,.123)',
+ 'rgba(5%,5%,5%,.321)',
+ 'rgba(0,0,0,1.00)',
+ 'rgba(0,0,0,0.12345)',
],
invalid: [
'rgb(0,0,0,)',
@@ -5130,12 +5134,10 @@ describe('Validators', () => {
'rgb()',
'rgba(0,0,0)',
'rgba(255,255,255,2)',
- 'rgba(255,255,255,.123)',
'rgba(255,255,256,0.1)',
'rgb(4,4,5%)',
'rgba(5%,5%,5%)',
'rgba(3,3,3%,.3)',
- 'rgba(5%,5%,5%,.321)',
'rgb(101%,101%,101%)',
'rgba(3%,3%,101%,0.3)',
'rgb(101%,101%,101%) additional invalid string part',
@@ -6596,6 +6598,11 @@ describe('Validators', () => {
'6765780016990268',
'8171999927660000',
'8171999900000000021',
+ '5108',
+ 'foo2222155765072228',
+ '2222155765072228foo',
+ '51080000000000',
+ '51080000000000000',
],
});
});
@@ -6980,6 +6987,22 @@ describe('Validators', () => {
'12345678!',
],
},
+ {
+ locale: 'ht-HT',
+ valid: [
+ 'A1234567890',
+ 'B9876543210',
+ 'Z0000000000',
+ 'a1234567890',
+ ],
+ invalid: [
+ '12345678901',
+ 'AB123456789',
+ 'A123456789',
+ 'A12345678901',
+ 'A123456789!',
+ ],
+ },
{
locale: 'zh-CN',
valid: [
@@ -8078,6 +8101,24 @@ describe('Validators', () => {
'064349089895623459',
],
},
+ {
+ locale: 'ht-HT',
+ valid: [
+ '+50923456789',
+ '+50931234567',
+ '+50941234567',
+ '23456789',
+ '31234567',
+ '41234567',
+ ],
+ invalid: [
+ '+50951234567',
+ '+50901234567',
+ '12345678',
+ '5091234567',
+ '123456',
+ ],
+ },
{
locale: 'hu-HU',
valid: [
@@ -10432,6 +10473,12 @@ describe('Validators', () => {
'+998957124555',
'998957124555',
'957124555',
+ '+998770178734',
+ '770178734',
+ '+998331234567',
+ '331234567',
+ '+998781234567',
+ '781234567',
],
invalid: [
'+998644835244',
@@ -13542,6 +13589,11 @@ describe('Validators', () => {
'ECMJ4657496',
'TBJA7176445',
'AFFU5962593',
+ 'abcHLXU2008419',
+ 'HLXU2008419abc',
+ 'abcQJRZ123456',
+ 'QJRZ123456abc',
+ 'QJR,123456',
],
});
});
@@ -13567,6 +13619,11 @@ describe('Validators', () => {
'ECMJ4657496',
'TBJA7176445',
'AFFU5962593',
+ 'abcHLXU2008419',
+ 'HLXU2008419abc',
+ 'abcQJRZ123456',
+ 'QJRZ123456abc',
+ 'QJR,123456',
],
});
});