From d64d2e0d10ccecc1459719f867b27f011ec67edf Mon Sep 17 00:00:00 2001 From: manuelaidos123 Date: Mon, 9 Feb 2026 22:30:42 +0000 Subject: [PATCH] feat: add Haiti (ht-HT) support to isIdentityCard Add validation for Haiti National Identity Card (CIN) and mobile phone numbers. - `isIdentityCard`: validates CIN format (1 letter followed by 10 digits). - `isMobilePhone`: validates Haiti mobile phone format. --- src/lib/isIdentityCard.js | 16 +++++++++++++++- src/lib/isMobilePhone.js | 3 ++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/lib/isIdentityCard.js b/src/lib/isIdentityCard.js index fc37d4a29..413faa51c 100644 --- a/src/lib/isIdentityCard.js +++ b/src/lib/isIdentityCard.js @@ -235,6 +235,20 @@ const validators = { } return true; }, + '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-Za-z]\d{10}$/; + + // sanitize user input + const sanitized = str.trim().toUpperCase(); + + // validate the data structure + if (!CIN.test(sanitized)) { + return false; + } + return true; + }, 'zh-CN': (str) => { const provincesAndCities = [ '11', // 北京 @@ -452,4 +466,4 @@ export default function isIdentityCard(str, locale) { return false; } throw new Error(`Invalid locale '${locale}'`); -} +} \ No newline at end of file diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index b00391ea6..1d0abd49a 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -110,6 +110,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}$/, @@ -210,4 +211,4 @@ export default function isMobilePhone(str, locale, options) { throw new Error(`Invalid locale '${locale}'`); } -export const locales = Object.keys(phones); +export const locales = Object.keys(phones); \ No newline at end of file