import { z } from "zod"; export const softwareSchema = z.object({ name: z.string().trim().min(1, "Yazılım adı zorunlu.").max(255), version: z.string().trim().max(50).optional().transform((v) => (v ? v : undefined)), description: z .string() .trim() .max(2000) .optional() .transform((v) => (v ? v : undefined)), defaultFee: z .union([z.number(), z.string()]) .optional() .transform((v) => { if (v === undefined || v === "") return undefined; const n = typeof v === "string" ? Number(v.replace(",", ".")) : v; return Number.isFinite(n) ? n : undefined; }), }); export type SoftwareInput = z.infer; export const customerSoftwareSchema = z.object({ customerId: z.string().min(1, "Müşteri seçin."), softwareId: z.string().min(1, "Yazılım seçin."), startDate: z.string().optional().transform((v) => (v ? v : undefined)), endDate: z.string().optional().transform((v) => (v ? v : undefined)), fee: z .union([z.number(), z.string()]) .optional() .transform((v) => { if (v === undefined || v === "") return undefined; const n = typeof v === "string" ? Number(v.replace(",", ".")) : v; return Number.isFinite(n) ? n : undefined; }), billingPeriod: z.enum(["monthly", "yearly", "onetime"]).optional().default("monthly"), notes: z.string().trim().max(1000).optional().transform((v) => (v ? v : undefined)), }); export type CustomerSoftwareInput = z.infer;