Skip to content

Commit d64d2e0

Browse files
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.
1 parent 88e0d3d commit d64d2e0

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/lib/isIdentityCard.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,20 @@ const validators = {
235235
}
236236
return true;
237237
},
238+
'ht-HT': (str) => {
239+
// Haiti National Identity Card (CIN - Carte d'Identité Nationale)
240+
// Format: 1 letter followed by 10 digits (11 characters total)
241+
const CIN = /^[A-Za-z]\d{10}$/;
242+
243+
// sanitize user input
244+
const sanitized = str.trim().toUpperCase();
245+
246+
// validate the data structure
247+
if (!CIN.test(sanitized)) {
248+
return false;
249+
}
250+
return true;
251+
},
238252
'zh-CN': (str) => {
239253
const provincesAndCities = [
240254
'11', // 北京
@@ -452,4 +466,4 @@ export default function isIdentityCard(str, locale) {
452466
return false;
453467
}
454468
throw new Error(`Invalid locale '${locale}'`);
455-
}
469+
}

src/lib/isMobilePhone.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ const phones = {
110110
'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/,
111111
'fr-WF': /^(\+681)?\d{6}$/,
112112
'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,
113+
'ht-HT': /^(\+?509)?[2-4]\d{7}$/,
113114
'hu-HU': /^(\+?36|06)(20|30|31|50|70)\d{7}$/,
114115
'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
115116
'ir-IR': /^(\+98|0)?9\d{9}$/,
@@ -210,4 +211,4 @@ export default function isMobilePhone(str, locale, options) {
210211
throw new Error(`Invalid locale '${locale}'`);
211212
}
212213

213-
export const locales = Object.keys(phones);
214+
export const locales = Object.keys(phones);

0 commit comments

Comments
 (0)