Sha256: a947bb197392fd199b4cdc2a266dca2640ea6d89779e05d1706175beca8b8bde

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

module Aamva
  class Validator

    # Physical Description – Eye Color

    def self.day(day)
      return false unless length(day, min: DAY_LENGTH, max: DAY_LENGTH)
      return false unless DAY_MAPPING.keys.include?(day)

      true
    end

    # Document Expiration Date

    def self.dba(dbd)
      dbd.match?(/\A[\d+]{8,8}\z/)
    end

    # Customer ID Number

    def self.daq(daq)
      daq.match?(/\A[\d\w]{1,25}\z/)
    end

    # Document Issue Date

    def self.dbd(dbd)
      dbd.match?(/\A[\d+]{8,8}\z/)
    end

    # Date of Birth

    def self.dbb(dbb)
      dbb.match?(/\A[\d+]{8,8}\z/)
    end

    def self.dbc(dbc)
      return false unless length(dbc, min: 1, max: 1)
      return false unless DBC_MAPPING.keys.include?(dbc)

      true
    end

    def self.dcg(dcg)
      return false unless length(dcg, min: 3, max: 3)
      return false unless DCG_MAPPING.keys.include?(dcg)

      true
    end

    def self.dai(dai)
      return false unless length(dai, min: 1, max: 20)

      true
    end

    def self.dac(dac)
      return false unless length(dac, min: 1, max: MAX_DAC_LENGTH)

      true
    end

    def self.length(value, min:, max:)
      value.length >= min && value.length <= max
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aamva-0.1.0 lib/aamva/validator.rb