import { z } from 'zod';

export function safeParse<T>(schema: z.ZodSchema<T>, data: unknown): T {
  const parsed = schema.safeParse(data);
  if (!parsed.success) {
    console.warn('Failed to parse data', parsed.error);
    return data as T;
  }
  return parsed.data;
}
