import { z } from "zod";

export const customerSchema = z.object({
  name: z.string().trim().min(1, "İsim zorunlu.").max(255),
  email: z
    .union([z.string().email("Geçerli bir email girin."), z.literal("")])
    .optional()
    .transform((v) => (v ? v : undefined)),
  phone: z.string().trim().max(30).optional().transform((v) => (v ? v : undefined)),
  taxId: z.string().trim().max(50).optional().transform((v) => (v ? v : undefined)),
  taxOffice: z.string().trim().max(100).optional().transform((v) => (v ? v : undefined)),
  website: z.string().trim().max(255).optional().transform((v) => (v ? v : undefined)),
  address: z.string().trim().max(500).optional().transform((v) => (v ? v : undefined)),
  notes: z.string().trim().max(2000).optional().transform((v) => (v ? v : undefined)),
  status: z.enum(["active", "passive"]).optional().default("active"),
});

export type CustomerInput = z.infer<typeof customerSchema>;
