import type { ZodType } from "zod"; export function safeParseWithSchema(schema: ZodType, value: unknown): T | null { const parsed = schema.safeParse(value); return parsed.success ? parsed.data : null; } export function safeParseJsonWithSchema(schema: ZodType, raw: string): T | null { try { return safeParseWithSchema(schema, JSON.parse(raw)); } catch { return null; } }