import { z } from "zod";

export const packageSchema = z.object({
  name: z
    .string()
    .trim()
    .min(1, "Package name is required")
    .max(100, "Package name cannot exceed 100 characters"),

  description: z
    .string()
    .trim()
    .min(1, "Description is required")
    .max(500, "Description cannot exceed 500 characters"),

  credits: z
    .string()
    .min(1, "Credits are required")
    .refine(
      (value) => !Number.isNaN(Number(value)) && Number(value) > 0,
      "Credits must be a valid positive number",
    ),

  price: z
    .string()
    .min(1, "Price is required")
    .refine(
      (value) => !Number.isNaN(Number(value)) && Number(value) >= 0,
      "Price must be a valid number",
    ),

  isActive: z.enum(["true", "false"], {
    error: "Status is required",
  }),
});

export type PackageFormData = z.infer<typeof packageSchema>;
