adamcrussell

VIN Validation

Part of Perl Weekly Challenge 036 was to implement validator for Vehicle Identification Numbers (VINs). The Wikipedia article on VINs is very comprehensive and has more than enough information to solve this challenge.

ch-1.pl
ch-1.pl

Notes

We assume North American VINs. The validation process is as follows:

  • Confirm that the VIN has the required format, using a regular expression (Line 48).
  • Compute the checksum (Lines 52-57).
  • Verify the check digit (Line 59).
  • There is a lot of static data for this, the character/value transliterations and weights. I decided to use Readonly data structures for this.

References

If you would like to generate known good VINs for testing I highly recommend https://randomvin.com.

Comments for this post were locked by the author