MVP Build

This commit is contained in:
Eric Gullickson
2025-08-09 12:47:15 -05:00
parent 2e8816df7f
commit 8f5117a4e2
92 changed files with 5910 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
/**
* @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);
}