import { z } from "zod"

export const mileageFormSchema = z.object({
    miles: z.coerce.number({ message: "Miles is required" }).min(0, "Miles must be 0 or greater"),
    fuel_level: z.preprocess(
        (value) => (value === "" || value == null ? undefined : Number(value)),
        z.number().min(0, "Fuel level must be 0 or greater").max(100, "Fuel level cannot exceed 100").optional(),
    ),
    date: z.string().min(1, "Date is required"),
    time: z.string().min(1, "Time is required"),
    note: z.string().optional(),
})

export type MileageFormValues = z.infer<typeof mileageFormSchema>
