import { z } from "zod"; export const productModel = z.object({ id: z.number().optional(), linkId: z.string().min(8).max(32), title: z.string().min(1).max(64), description: z.string().min(1), longDescription: z.string().min(1), price: z.coerce.number().nonnegative(), discountPrice: z.coerce.number().nonnegative(), createdAt: z.coerce.string().optional(), updatedAt: z.coerce.string().optional(), }); export type ProductModel = z.infer; export const createProductPayload = productModel.omit({ id: true, linkId: true, createdAt: true, updatedAt: true, }); export type CreateProductPayload = z.infer; export const updateProductPayload = productModel .omit({ linkId: true, createdAt: true, updatedAt: true, }) .partial() .extend({ id: z.number(), }); export type UpdateProductPayload = z.infer;