Class: Aamva::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/aamva/validator.rb

Class Method Summary collapse

Class Method Details

.dac(dac) ⇒ Object



57
58
59
60
61
# File 'lib/aamva/validator.rb', line 57

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

  true
end

.dai(dai) ⇒ Object



51
52
53
54
55
# File 'lib/aamva/validator.rb', line 51

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

  true
end

.daq(daq) ⇒ Object

Customer ID Number



21
22
23
# File 'lib/aamva/validator.rb', line 21

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

.day(day) ⇒ Object

Physical Description – Eye Color



6
7
8
9
10
11
# File 'lib/aamva/validator.rb', line 6

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

.dba(dbd) ⇒ Object

Document Expiration Date



15
16
17
# File 'lib/aamva/validator.rb', line 15

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

.dbb(dbb) ⇒ Object

Date of Birth



33
34
35
# File 'lib/aamva/validator.rb', line 33

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

.dbc(dbc) ⇒ Object



37
38
39
40
41
42
# File 'lib/aamva/validator.rb', line 37

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

  true
end

.dbd(dbd) ⇒ Object

Document Issue Date



27
28
29
# File 'lib/aamva/validator.rb', line 27

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

.dcg(dcg) ⇒ Object



44
45
46
47
48
49
# File 'lib/aamva/validator.rb', line 44

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

  true
end

.length(value, min:, max:) ⇒ Object



63
64
65
# File 'lib/aamva/validator.rb', line 63

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