MooseX::Types::Vehicle - Moose Types for Vehicles (NHSTA 17 char VIN)


This module provide the type VIN17. This type can be used in Moose code.

    use MooseX::Types::Vehicle qw/VIN17/;

    has 'vin' => ( isa => VIN17, is => 'rw' );

Alternatively, you can have it automagically coerce to a VIN if possible:

    use MooseX::Types::Vehicle qw/VIN17/;
    has 'vin' => ( isa => VIN17, is => 'rw', coerce => 1 );

Lastly, all MooseX::Types modules can export a function for is_TYPE and to_TYPE.

    use MooseX::Types::Vehicle qw/to_VIN17 is_VIN17/;
    ## Return a VIN number without spaces, with the 'O' (letter) as '0' (number zero)
    ## 'I' (letter) as '1' (number one) and without spaces.
    to_VIN17( '3D7KS28C26G 18OO4I  ' );

    ## Returns 1 or 0 if the VIN is valid.
    is_VIN17( '3D7KS28C26G180041' );


This module currently only impliments the NHSTA 17 Digit VIN check and applicable coercions. Applicable coercions include trimming whitespace, and transliterating invalid characters to their valid coutnerparts "qQoO" (letter 'q' and 'o') to "0" (number zero), and "iI" (letter 'I') to '1' (number one).

This module assumes VINs must be uppercase to be valid. Lowercase characters are uppercased in coercion.

A VIN check is a checksum against the VIN.

For more information see the "SEE ALSO".


This module can export two functions both of which are explained in the synopsis.


Takes a string, returns a coerced string.


Determines whether or not a string is a valid 17 character VIN. Returns boolean 1 or 0.



This is the website of the NHTSA. They created this VIN shit. I never read any of their texts. Got any ideas on how to improve the VIN standard? I'm sure they'll be glad to listen to your advice.

This is a great resource for more information about the VIN numbers.


Evan Carroll, <me at>


Please report any bugs or feature requests to bug-moosex-types-vehicle at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

perldoc MooseX::Types::Vehicle

You can also look for information at:


Copyright 2012 Evan Carroll

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.