fix: edit vehicle null fix
All checks were successful
Deploy to Staging / Build Images (push) Successful in 4m32s
Deploy to Staging / Deploy to Staging (push) Successful in 27s
Deploy to Staging / Verify Staging (push) Successful in 6s
Deploy to Staging / Notify Staging Ready (push) Successful in 5s
Deploy to Staging / Notify Staging Failure (push) Has been skipped
All checks were successful
Deploy to Staging / Build Images (push) Successful in 4m32s
Deploy to Staging / Deploy to Staging (push) Successful in 27s
Deploy to Staging / Verify Staging (push) Successful in 6s
Deploy to Staging / Notify Staging Ready (push) Successful in 5s
Deploy to Staging / Notify Staging Failure (push) Has been skipped
This commit is contained in:
@@ -13,22 +13,25 @@ import { VehicleImageUpload } from './VehicleImageUpload';
|
||||
|
||||
const vehicleSchema = z
|
||||
.object({
|
||||
vin: z.string().optional(),
|
||||
year: z.number().min(1950).max(new Date().getFullYear() + 1).optional(),
|
||||
make: z.string().optional(),
|
||||
model: z.string().optional(),
|
||||
engine: z.string().optional(),
|
||||
transmission: z.string().optional(),
|
||||
trimLevel: z.string().optional(),
|
||||
driveType: z.string().optional(),
|
||||
fuelType: z.string().optional(),
|
||||
nickname: z.string().optional(),
|
||||
color: z.string().optional(),
|
||||
licensePlate: z.string().optional(),
|
||||
odometerReading: z.number().min(0).optional(),
|
||||
vin: z.string().nullable().optional().transform(val => val ?? undefined),
|
||||
year: z.number().min(1950).max(new Date().getFullYear() + 1).nullable().optional(),
|
||||
make: z.string().nullable().optional(),
|
||||
model: z.string().nullable().optional(),
|
||||
engine: z.string().nullable().optional(),
|
||||
transmission: z.string().nullable().optional(),
|
||||
trimLevel: z.string().nullable().optional(),
|
||||
driveType: z.string().nullable().optional(),
|
||||
fuelType: z.string().nullable().optional(),
|
||||
nickname: z.string().nullable().optional(),
|
||||
color: z.string().nullable().optional(),
|
||||
licensePlate: z.string().nullable().optional(),
|
||||
odometerReading: z.number().min(0).nullable().optional(),
|
||||
})
|
||||
.refine(
|
||||
(data) => {
|
||||
// Pre-1981 vehicles have no VIN/plate requirement
|
||||
if (data.year && data.year < 1981) return true;
|
||||
|
||||
const vin = (data.vin || '').trim();
|
||||
const plate = (data.licensePlate || '').trim();
|
||||
// Must have either a valid 17-char VIN or a non-empty license plate
|
||||
@@ -43,6 +46,9 @@ const vehicleSchema = z
|
||||
)
|
||||
.refine(
|
||||
(data) => {
|
||||
// Pre-1981 vehicles have no VIN format requirement
|
||||
if (data.year && data.year < 1981) return true;
|
||||
|
||||
const vin = (data.vin || '').trim();
|
||||
const plate = (data.licensePlate || '').trim();
|
||||
// If VIN provided but not 17 and no plate, fail; if plate exists, allow any VIN (or empty)
|
||||
|
||||
Reference in New Issue
Block a user