fix: Short VIN Storage - Issue #1
All checks were successful
Deploy to Staging / Build Images (push) Successful in 4m31s
Deploy to Staging / Deploy to Staging (push) Successful in 36s
Deploy to Staging / Verify Staging (push) Successful in 5s
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:
Eric Gullickson
2026-01-01 10:05:56 -06:00
parent 7631d961c5
commit f79fda79b9
9 changed files with 109 additions and 29 deletions

View File

@@ -19,12 +19,20 @@ export function isValidUUID(uuid: string): boolean {
}
export function isValidVIN(vin: string): boolean {
// VIN must be exactly 17 characters
// VIN must be exactly 17 characters (modern VIN standard since 1981)
if (vin.length !== 17) return false;
// VIN cannot contain I, O, or Q
if (/[IOQ]/i.test(vin)) return false;
// Must be alphanumeric
return /^[A-HJ-NPR-Z0-9]{17}$/i.test(vin);
}
export function isValidPreModernVIN(vin: string): boolean {
// Pre-1981 vehicles had non-standardized VINs of varying lengths (1-17 characters)
if (vin.length < 1 || vin.length > 17) return false;
// Must be alphanumeric (allow I, O, Q for pre-1981 as they weren't banned yet)
return /^[A-Z0-9]+$/i.test(vin);
}