/** * @ai-summary Input validation for fuel logs API */ import { z } from 'zod'; export const createFuelLogSchema = z.object({ vehicleId: z.string().uuid(), date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/), odometer: z.number().int().positive(), gallons: z.number().positive(), pricePerGallon: z.number().positive(), totalCost: z.number().positive(), station: z.string().max(200).optional(), location: z.string().max(200).optional(), notes: z.string().max(1000).optional(), }); export const updateFuelLogSchema = z.object({ date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(), odometer: z.number().int().positive().optional(), gallons: z.number().positive().optional(), pricePerGallon: z.number().positive().optional(), totalCost: z.number().positive().optional(), station: z.string().max(200).optional(), location: z.string().max(200).optional(), notes: z.string().max(1000).optional(), }).refine(data => Object.keys(data).length > 0, { message: 'At least one field must be provided for update' }); export function validateCreateFuelLog(data: unknown) { return createFuelLogSchema.safeParse(data); } export function validateUpdateFuelLog(data: unknown) { return updateFuelLogSchema.safeParse(data); }