Gem for gathering info on VINs, optionally using NHTSA’s API

Installation

Add this line to your application’s Gemfile:

gem 'vin-validator'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install vin-validator

Usage

vin_info

just_a_vin = 'AA5325L1588827'
other_vins = %w[13N153201K1533942 1E9AA5325L1588827 1RND48A27GR039983 1RND53A33KR049282]

VinValidator::Knowledge.vin_info(just_a_vin).fetch(just_a_vin)

VinValidator::Knowledge.vin_info(just_a_vin, true).fetch(just_a_vin)

VinValidator::Knowledge.vin_info(other_vins)

VinValidator::Knowledge.vin_info(other_vins, true)

Every call to VinValidator::Knowledge::vin_info will return a hash. Each key in the result is one of the VINs provided, and each value is another hash.

Value hash:

Key Value

:errors

Array<VinValidator::Result>

:nhtsa_errors

Array<VinValidator::Result>

:vin

VinValidator::Result

:make

Array<VinValidator::Result>

:manufacturer

VinValidator::Result

:model

VinValidator::Result

:year

VinValidator::Result

:body_type

VinValidator::Result

:trailer_type

VinValidator::Result

:vehicle_type

VinValidator::Result

:gvw

VinValidator::Result

:suggested_vin

VinValidator::Result

VinValidator::Result has 3 attributes: vin, type, and value.

  • vin - The vin the result belongs to

  • type - The type of result (error, make, year, etc)

  • value - The value of the result

validate

just_a_vin = 'AA5325L1588827'
other_vins = %w[13N153201K1533942 1E9AA5325L1588827 1RND48A27GR039983 1RND53A33KR049282]

VinValidator::Knowledge.validate(just_a_vin).fetch(just_a_vin)

VinValidator::Knowledge.validate(just_a_vin, true).fetch(just_a_vin)

VinValidator::Knowledge.validate(other_vins)

VinValidator::Knowledge.validate(other_vins, true)

Every call to VinValidator::Knowledge::vin_info will return a hash. Each key in the result is one of the VINs provided, and each value is another hash.

Value hash:

Key Value Description

:valid

Boolean

false if there are errors or year/wmi is blank

:year

Hash, Nil

:letter(String) and :year(Integer)

:wmi

Array<VinValidator::Result>

Possible makes the VIN can have

:infos

Array<String>

The info messages

:errors

Array<String>

The error messages

VinValidator::Result has 3 attributes: vin, type, and value.

  • vin - The vin the result belongs to

  • type - The type of result (error, make, year, etc)

  • value - The value of the result

Changelog

See CHANGELOG see changes