Sha256: c1a041765a670d676ba3ef1c7bb500ed2c44c6c4177d4d8a4dde12ef6d8bc797

Contents?: true

Size: 605 Bytes

Versions: 3

Compression:

Stored size: 605 Bytes

Contents

# frozen_string_literal: true

module Vindetta
  class Validator
    attr_reader :standard

    def initialize(standard)
      @standard = standard
    end

    def vin(vin)
      return false unless vin.length == standard.length

      Calculator.check_digit(vin) == Decoder.new(Vindetta::Standard::ISO3779).vin(vin)[:check_digit]
    rescue Calculator::InvalidCharacterError
      false
    end

    def wmi(wmi)
      wmi.length == standard.wmi.length
    end

    def vds(vds)
      vds.length == standard.vds.length
    end

    def vis(vis)
      vis.length == standard.vis.length
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vindetta-0.28.0 lib/vindetta/validator.rb
vindetta-0.27.0 lib/vindetta/validator.rb
vindetta-0.26.0 lib/vindetta/validator.rb