// Small shared coercers for DTO fields that arrive as strings from JSON. // Distinguishing "field absent" (undefined -> leave unchanged) from // "field cleared" (null/"" -> set null) matters for PATCH semantics. export function toDate(v?: string | null): Date | null | undefined { if (v === undefined) return undefined; if (v === "" || v === null) return null; const d = new Date(v); return isNaN(d.getTime()) ? undefined : d; }