Spaces:
Sleeping
Sleeping
File size: 725 Bytes
1e65df5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | export const normalizeCustomerName = (value = "") => {
return String(value || "")
.trim()
.replace(/\s+/g, " ")
.replace(/[\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06ED]/g, "")
.replace(/ـ/g, "")
.replace(/[أإآٱ]/g, "ا")
.replace(/ؤ/g, "و")
.replace(/ئ/g, "ي")
.replace(/ى/g, "ي")
.toLowerCase();
};
export const normalizeCustomerPhone = (value = "") => {
let digits = String(value || "").replace(/\D/g, "");
if (!digits) return "";
if (digits.startsWith("0") && digits.length === 11) {
digits = `20${digits.slice(1)}`;
} else if (digits.length === 10 && digits.startsWith("1")) {
digits = `20${digits}`;
}
return digits;
};
|