/** * Shared input sanitization for public registration endpoints. */ export function sanitizeName(name: unknown): string | null { if (!name || typeof name !== "string") return null; const clean = name.trim().slice(0, 100); return clean || null; } export function sanitizePhone(phone: unknown): string | null { if (!phone || typeof phone !== "string") return null; const clean = phone.replace(/\D/g, "").slice(0, 15); return clean.length >= 9 ? clean : null; } export function sanitizeHandle(value: unknown): string | undefined { if (!value || typeof value !== "string") return undefined; const clean = value.trim().slice(0, 100); return clean || undefined; } export function sanitizeText(value: unknown, maxLength: number = 200): string | undefined { if (!value || typeof value !== "string") return undefined; const clean = value.trim().slice(0, maxLength); return clean || undefined; }