license-validator 0.0.0 → 1.0.0.pre.rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/lib/license-validator.rb +114 -0
  3. data/lib/license_validator/driver.rb +67 -0
  4. data/lib/license_validator/states.rb +14 -0
  5. data/lib/license_validator/validations/base.rb +62 -0
  6. data/lib/license_validator/validations/state_ak.rb +24 -0
  7. data/lib/license_validator/validations/state_al.rb +26 -0
  8. data/lib/license_validator/validations/state_ar.rb +20 -0
  9. data/lib/license_validator/validations/state_az.rb +31 -0
  10. data/lib/license_validator/validations/state_ca.rb +20 -0
  11. data/lib/license_validator/validations/state_co.rb +23 -0
  12. data/lib/license_validator/validations/state_ct.rb +39 -0
  13. data/lib/license_validator/validations/state_dc.rb +24 -0
  14. data/lib/license_validator/validations/state_de.rb +16 -0
  15. data/lib/license_validator/validations/state_fl.rb +16 -0
  16. data/lib/license_validator/validations/state_ga.rb +28 -0
  17. data/lib/license_validator/validations/state_hi.rb +27 -0
  18. data/lib/license_validator/validations/state_ia.rb +22 -0
  19. data/lib/license_validator/validations/state_id.rb +27 -0
  20. data/lib/license_validator/validations/state_il.rb +16 -0
  21. data/lib/license_validator/validations/state_in.rb +16 -0
  22. data/lib/license_validator/validations/state_ks.rb +24 -0
  23. data/lib/license_validator/validations/state_ky.rb +19 -0
  24. data/lib/license_validator/validations/state_la.rb +16 -0
  25. data/lib/license_validator/validations/state_ma.rb +22 -0
  26. data/lib/license_validator/validations/state_md.rb +22 -0
  27. data/lib/license_validator/validations/state_me.rb +16 -0
  28. data/lib/license_validator/validations/state_mi.rb +16 -0
  29. data/lib/license_validator/validations/state_mn.rb +16 -0
  30. data/lib/license_validator/validations/state_mo.rb +28 -0
  31. data/lib/license_validator/validations/state_ms.rb +16 -0
  32. data/lib/license_validator/validations/state_mt.rb +39 -0
  33. data/lib/license_validator/validations/state_nc.rb +24 -0
  34. data/lib/license_validator/validations/state_nd.rb +19 -0
  35. data/lib/license_validator/validations/state_ne.rb +16 -0
  36. data/lib/license_validator/validations/state_nh.rb +30 -0
  37. data/lib/license_validator/validations/state_nj.rb +16 -0
  38. data/lib/license_validator/validations/state_nm.rb +16 -0
  39. data/lib/license_validator/validations/state_nv.rb +21 -0
  40. data/lib/license_validator/validations/state_ny.rb +28 -0
  41. data/lib/license_validator/validations/state_oh.rb +19 -0
  42. data/lib/license_validator/validations/state_ok.rb +20 -0
  43. data/lib/license_validator/validations/state_or.rb +24 -0
  44. data/lib/license_validator/validations/state_pa.rb +20 -0
  45. data/lib/license_validator/validations/state_ri.rb +19 -0
  46. data/lib/license_validator/validations/state_sc.rb +16 -0
  47. data/lib/license_validator/validations/state_sd.rb +19 -0
  48. data/lib/license_validator/validations/state_tn.rb +20 -0
  49. data/lib/license_validator/validations/state_tx.rb +24 -0
  50. data/lib/license_validator/validations/state_ut.rb +16 -0
  51. data/lib/license_validator/validations/state_va.rb +16 -0
  52. data/lib/license_validator/validations/state_vt.rb +16 -0
  53. data/lib/license_validator/validations/state_wa.rb +23 -0
  54. data/lib/license_validator/validations/state_wi.rb +16 -0
  55. data/lib/license_validator/validations/state_wv.rb +26 -0
  56. data/lib/license_validator/validations/state_wy.rb +16 -0
  57. data/lib/license_validator/validators.rb +5 -0
  58. data/lib/license_validator/version.rb +1 -1
  59. metadata +87 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f87d7f82477a2235831fa7bde0b2571cc60cc497968c032025d4de7009685d87
4
- data.tar.gz: 49b4763e53ae8eb56ced5a57835e45f879d687fffd5be4ed9740ecbca8f34aaf
3
+ metadata.gz: 8fe7ae2eee4e5a9431670aa6db06aaa0de42016ac56fc2637ff8ff5ea87b238f
4
+ data.tar.gz: f846963096f33090ce563ed7f27d1b18d0ff4a19caa9420a9c6cc70f04248e80
5
5
  SHA512:
6
- metadata.gz: 5c114aa2a168430f45c70f9fac41885a989b15800d6bea4cc20c91b9ed99ce185f6454fbf410ae06affe540347fad02150327e3c91ed62db96acc41567b59528
7
- data.tar.gz: d24b0a625aadc735460faadee07e3b086706bef76a4ffaa074e7a3cc6288b3bf4e49ac81e85786345c5065a555c262d38fc0275a475a1d05b318f833d7436f36
6
+ metadata.gz: ec6ce697e9fd2fd393857ae643f6bc136adb8be738f41327ca7ecbc12208d8b92d7f979cfb9576432360f835319b428afd3778e8794256a535d8d816f015b7fc
7
+ data.tar.gz: 9b346187ac19b067622d7d8b691488093779bac7e39ff6177e8bd94c305744e0bb5d36f96292c2d5533570e84813f16e287e0754b1b52c2aa4e5d84753514a9e
@@ -1,6 +1,120 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_model'
4
+
5
+ require_relative 'license_validator/states'
6
+
7
+ require_relative 'license_validator/driver'
8
+ require_relative 'license_validator/validators'
3
9
  require_relative 'license_validator/version'
4
10
 
5
11
  module LicenseValidator
12
+ # Validates the provided driver's DL#
13
+ #
14
+ # @param @see LicenseValidator::Driver attributes
15
+ #
16
+ # @raise [ActiveModel::ValidationError] if driver is invalid
17
+ #
18
+ # @return [Hash]
19
+ #
20
+ def validate!(**kwargs)
21
+ driver = LicenseValidator::Driver.new(**kwargs)
22
+
23
+ puts(driver)
24
+
25
+ validator =
26
+ LicenseValidator::Validations
27
+ .const_get("LicenseValidator::Validations::State#{driver.state.capitalize}")
28
+ .new(driver)
29
+
30
+ validator.validate
31
+
32
+ return validator.validation_results
33
+ end
34
+
35
+ module_function :validate!
36
+
37
+ private
38
+
39
+ # Only for development
40
+ def generate_state_files
41
+ LicenseValidator::States::ABVS.each do |abv|
42
+ ruby = <<~RUBY
43
+ # frozen_string_literal: true
44
+
45
+ module LicenseValidator
46
+ module Validations
47
+ class State#{abv.capitalize} < LicenseValidator::Validations::Base
48
+ def initialize(driver)
49
+ super(driver)
50
+ end
51
+
52
+ # @see super
53
+ def validate
54
+ super
55
+ end
56
+ end
57
+ end
58
+ end
59
+ RUBY
60
+
61
+ File.write("lib/license_validator/validations/state_#{abv.downcase}.rb", ruby)
62
+ end
63
+ end
64
+
65
+ module_function :generate_state_files
66
+
67
+ # Only for development
68
+ def generate_test_files
69
+ LicenseValidator::States::ABVS.each do |abv|
70
+ test = <<~SPEC
71
+ # frozen_string_literal: true
72
+
73
+ state_klass = LicenseValidator::Validations::State#{abv.capitalize}
74
+
75
+ module ValidAttributes
76
+ module State#{abv.capitalize}
77
+ # @see super
78
+ def valid_attributes
79
+ super.map do |valid_attrs|
80
+ valid_attrs
81
+ end
82
+ end
83
+
84
+ # @see super
85
+ def invalid_attributes
86
+ super.map do |invalid_attrs|
87
+ invalid_attrs
88
+ end
89
+ end
90
+
91
+ private
92
+
93
+ # @see super
94
+ def valid_license_nums
95
+ %w[AB123456]
96
+ end
97
+
98
+ # @see super
99
+ def invalid_license_nums
100
+ %w[AB]
101
+ end
102
+
103
+ # @see super
104
+ def state
105
+ '#{abv}'
106
+ end
107
+ end
108
+ end
109
+
110
+ state_klass.extend(ValidAttributes::State#{abv.capitalize})
111
+
112
+ test_klass(state_klass)
113
+ SPEC
114
+
115
+ File.write("spec/license_validator/validations/state_#{abv.downcase}_spec.rb", test)
116
+ end
117
+ end
118
+
119
+ module_function :generate_test_files
6
120
  end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ class Driver
5
+ include ActiveModel::Model
6
+
7
+ validates :license_num, presence: true
8
+ validates :cdl_class, inclusion: { in: ['A', 'B', 'No CDL'], message: 'is invalid' }
9
+ validates :state, inclusion: { in: LicenseValidator::States::ABVS, message: 'is invalid' }
10
+ validates :years_exp, numericality: { greater_than_or_equal_to: 0 }
11
+ validates :age, numericality: { greater_than_or_equal_to: 0 }, if: -> (d) { d.dob.present? }
12
+
13
+ # @return [String] abv
14
+ attr_accessor :state
15
+ # @return [Integer]
16
+ attr_accessor :years_exp
17
+ # @return [Date]
18
+ attr_accessor :dob
19
+ # @return [Integer]
20
+ attr_accessor :age
21
+ # @return [String]
22
+ attr_accessor :cdl_class
23
+ # @return [String]
24
+ attr_accessor :license_num
25
+ # @return [String]
26
+ attr_accessor :first_name
27
+ # @return [String]
28
+ attr_accessor :last_name
29
+ # @return [Boolean]
30
+ attr_accessor :bad
31
+
32
+ # @see super
33
+ def self.human_attribute_name(attr, options = {})
34
+ return 'CDL Class' if attr == 'cdl_class'
35
+ return 'License #' if attr == 'license_num'
36
+
37
+ super
38
+ end
39
+
40
+ def initialize(attributes = {})
41
+ super
42
+
43
+ if dob.blank? && !dob.is_a?(Date)
44
+ @dob = nil
45
+ end
46
+
47
+ @license_num = license_num.to_s
48
+
49
+ validate!
50
+ end
51
+
52
+ # @return [Hash]
53
+ def attributes
54
+ {
55
+ state: state,
56
+ years_exp: years_exp,
57
+ dob: dob,
58
+ age: age,
59
+ cdl_class: cdl_class,
60
+ license_num: license_num,
61
+ first_name: first_name,
62
+ last_name: last_name,
63
+ bad: bad
64
+ }
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module States
5
+ ABVS = %w[
6
+ AK AL AR AZ CA CO CT DE FL GA
7
+ HI IA ID IL IN KS KY LA MA MD
8
+ ME MI MN MO MS MT NC ND NE NH
9
+ NJ NM NV NY OH OK OR PA RI SC
10
+ SD TN TX UT VA VT WA WI WV WY
11
+ DC
12
+ ].freeze
13
+ end
14
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module Validations
5
+ class Base
6
+ # @return [ActiveModel::Errors]
7
+ attr_accessor :errors
8
+ # @return [ActiveModel::Errors]
9
+ attr_accessor :warnings
10
+ # @return [ActiveModel::Errors]
11
+ attr_accessor :infos
12
+ # @return [LicenseValidator::Driver]
13
+ attr_accessor :driver
14
+
15
+ def initialize(driver)
16
+ @errors = ActiveModel::Errors.new(self)
17
+ @warnings = ActiveModel::Errors.new(self)
18
+ @infos = ActiveModel::Errors.new(self)
19
+
20
+ @driver = driver
21
+ end
22
+
23
+ # Common validations
24
+ def validate
25
+ return if driver.dob.nil?
26
+
27
+ age = driver.age
28
+
29
+ if age < 21
30
+ warnings.add(:dob, 'Drivers under 21 do not qualify for an interstate CDL.')
31
+ elsif age < 23
32
+ warnings.add(
33
+ :dob,
34
+ 'Drivers under 23 are underage for all markets unless underwriters have specifically approved.'
35
+ )
36
+ elsif age > 65
37
+ warnings.add(
38
+ :dob,
39
+ [
40
+ 'Drivers is older than 65, check underwriting guidelines to determine if they should be submitted',
41
+ 'for approval.'
42
+ ].join(' ')
43
+ )
44
+ end
45
+
46
+ return unless driver.bad
47
+
48
+ warnings.add(:bad, 'Driver is on the bad drivers list.')
49
+ end
50
+
51
+ # @return [Hash]
52
+ def validation_results
53
+ {
54
+ errors: errors,
55
+ warnings: warnings,
56
+ infos: infos,
57
+ validated_with: driver.attributes
58
+ }
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module Validations
5
+ class StateAk < LicenseValidator::Validations::Base
6
+ # @see super
7
+ def validate
8
+ super
9
+
10
+ unless driver.license_num.match?(/\A\d{7}\z/i)
11
+ errors.add(:license_num, 'License number requires 7 numeric digits for AK.')
12
+ end
13
+
14
+ if driver.last_name.blank?
15
+ errors.add(:last_name, 'Last name required for AK.')
16
+ end
17
+
18
+ return if driver.dob.present?
19
+
20
+ errors.add(:dob, 'D.O.B. required for AK.')
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module Validations
5
+ class StateAl < LicenseValidator::Validations::Base
6
+ # @see super
7
+ def validate
8
+ super
9
+
10
+ lic_num = driver.license_num
11
+
12
+ return if lic_num.match?(/\A\d{7,8}\z/i)
13
+ return if lic_num.match?(/\A[a-z]\d{6,8}\z/i)
14
+ return if lic_num.match?(/\AID\d{5,6}\z/i)
15
+
16
+ errors.add(
17
+ :license_num,
18
+ [
19
+ 'License number requires 7-8 Numeric or "I", 6-8 Numeric or "ID", 5-6 Numeric or 1 Alphabetic, 6-8 Numeric',
20
+ 'for AL'
21
+ ].join(' ')
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module Validations
5
+ class StateAr < LicenseValidator::Validations::Base
6
+ # @see super
7
+ def validate
8
+ super
9
+
10
+ unless driver.license_num.match?(/\A\d{9}\z/i)
11
+ errors.add(:license_num, 'License number requires 9 numeric digits for AR.')
12
+ end
13
+
14
+ return if driver.dob.present?
15
+
16
+ errors.add(:dob, 'D.O.B. is required for AR.')
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module Validations
5
+ class StateAz < LicenseValidator::Validations::Base
6
+ # @see super
7
+ def validate
8
+ super
9
+
10
+ if driver.last_name.blank?
11
+ errors.add(:last_name, 'Last name required for AZ.')
12
+ end
13
+
14
+ if driver.first_name.blank?
15
+ errors.add(:first_name, 'First name required for AZ.')
16
+ end
17
+
18
+ if driver.dob.blank?
19
+ errors.add(:dob, 'D.O.B. required for AZ.')
20
+ end
21
+
22
+ lic_num = driver.license_num
23
+
24
+ return if lic_num.match?(/\A[a-z]\d{8}\z/i)
25
+ return if lic_num.match?(/\A\d{9}\z/i)
26
+
27
+ errors.add(:license_num, 'License number requires 1 Alphabetic, 8 Numeric or 9 Numeric for AZ.')
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module Validations
5
+ class StateCa < LicenseValidator::Validations::Base
6
+ # @see super
7
+ def validate
8
+ super
9
+
10
+ unless driver.license_num.match?(/\A[a-z]\d{7}\z/i)
11
+ errors.add(:license_num, 'License number requires 1 Alphabetic, 7 Numeric for CA.')
12
+ end
13
+
14
+ return if driver.last_name.present?
15
+
16
+ errors.add(:last_name, 'Last name required for CA.')
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module Validations
5
+ class StateCo < LicenseValidator::Validations::Base
6
+ # @see super
7
+ def validate
8
+ super
9
+
10
+ if driver.dob.blank?
11
+ errors.add(:dob, 'D.O.B. is required for CO.')
12
+ end
13
+
14
+ lic_num = driver.license_num
15
+
16
+ return if lic_num.match?(/\A\d{9}\z/i)
17
+ return if lic_num.match?(/\A[a-z]\d{3,6}\z/i)
18
+
19
+ errors.add(:license_num, 'License number requires 9 numeric or 1 alphabetic, 3-6 numeric for CO.')
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module Validations
5
+ class StateCt < LicenseValidator::Validations::Base
6
+ # @see super
7
+ def validate
8
+ super
9
+
10
+ if driver.last_name.blank?
11
+ errors.add(:last_name, 'Last name required for CT.')
12
+ end
13
+
14
+ # 9 Numeric, 1st two positions are month of birth in odd or
15
+ # even year. 01-12 Jan-Dec odd years, 13 - 24 Jan-Dec even years, 99 unknown
16
+
17
+ if driver.dob.blank?
18
+ errors.add(:dob, 'D.O.B. is required for CT.')
19
+
20
+ return
21
+ end
22
+
23
+ year = driver.dob.year
24
+ month = driver.dob.month
25
+ month += 12 if year.even?
26
+ month = "#{0 if month < 10}#{month}"
27
+
28
+ regex = Regexp.new("\\A#{month}\\d{7}\\z", 'i')
29
+
30
+ return if driver.license_num.match?(regex)
31
+
32
+ errors.add(
33
+ :license_num,
34
+ "License number requires 9 numeric for CT. For DOB in #{year}, license number must start with #{month}"
35
+ )
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module Validations
5
+ class StateDc < LicenseValidator::Validations::Base
6
+ # @see super
7
+ def validate
8
+ super
9
+
10
+ unless driver.license_num.match?(/\A[a-z0-9]{7,9}\z/i)
11
+ errors.add(:license_num, 'License number requires 7-9 alphanumeric for DC.')
12
+ end
13
+
14
+ if driver.last_name.blank?
15
+ errors.add(:last_name, 'Last name required for DC.')
16
+ end
17
+
18
+ return if driver.dob.present?
19
+
20
+ errors.add(:dob, 'D.O.B. required for DC.')
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module Validations
5
+ class StateDe < LicenseValidator::Validations::Base
6
+ # @see super
7
+ def validate
8
+ super
9
+
10
+ return if driver.license_num.match?(/\A\d{1,7}\z/i)
11
+
12
+ errors.add(:license_num, 'License requires 1-7 numeric for DE.')
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module Validations
5
+ class StateFl < LicenseValidator::Validations::Base
6
+ # @see super
7
+ def validate
8
+ super
9
+
10
+ return if driver.license_num.match?(/\A[a-zA-Z]\d{12}\z/i)
11
+
12
+ errors.add(:license_num, 'License number requires 1 alphabetic and 12 numeric for FL.')
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module Validations
5
+ class StateGa < LicenseValidator::Validations::Base
6
+ # @see super
7
+ def validate
8
+ super
9
+
10
+ unless driver.license_num.match?(/\A\d{9}\z/i)
11
+ errors.add(:license_num, 'License number requires 9 numeric digits for GA.')
12
+ end
13
+
14
+ if driver.first_name.blank?
15
+ errors.add(:first_name, 'First name required for GA.')
16
+ end
17
+
18
+ if driver.last_name.blank?
19
+ errors.add(:last_name, 'Last name required for GA.')
20
+ end
21
+
22
+ return if driver.dob.present?
23
+
24
+ errors.add(:dob, 'D.O.B. required for GA.')
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module Validations
5
+ class StateHi < LicenseValidator::Validations::Base
6
+ # @see super
7
+ def validate
8
+ super
9
+
10
+ if driver.last_name.blank?
11
+ errors.add(:last_name, 'Last name required for HI.')
12
+ end
13
+
14
+ if driver.dob.blank?
15
+ errors.add(:dob, 'D.O.B. required for HI.')
16
+ end
17
+
18
+ lic_num = driver.license_num
19
+
20
+ return if lic_num.match?(/\A\d{9}\z/i)
21
+ return if lic_num.match?(/\AH\d{8}\z/i)
22
+
23
+ errors.add(:license_num, 'License number needs 9 numeric or "H", 8 numeric for HI.')
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module Validations
5
+ class StateIa < LicenseValidator::Validations::Base
6
+ # @see super
7
+ def validate
8
+ super
9
+
10
+ lic_num = driver.license_num
11
+
12
+ return if lic_num.match?(/\A\d{3}[a-z]{2}\d{4}\z/i)
13
+ return if lic_num.match?(/\A\d{9}\z/i)
14
+
15
+ errors.add(
16
+ :license_num,
17
+ 'License number requires 3 Numeric and 2 Alphabetic and 4 Numeric, or 9 numeric for IA.'
18
+ )
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module Validations
5
+ class StateId < LicenseValidator::Validations::Base
6
+ # @see super
7
+ def validate
8
+ super
9
+
10
+ if driver.last_name.blank?
11
+ errors.add(:last_name, 'Last name required for ID.')
12
+ end
13
+
14
+ if driver.dob.blank?
15
+ errors.add(:dob, 'D.O.B. required for ID.')
16
+ end
17
+
18
+ lic_num = driver.license_num
19
+
20
+ return if lic_num.match?(/\A[a-z]{2}\d{6}[a-z]\z/i)
21
+ return if lic_num.match?(/\A\d{9}\z/i)
22
+
23
+ errors.add(:license_num, 'License number requires 2 Alphabetic, 6 Numeric, 1 Alphabetic or 9 Numeric for ID.')
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module Validations
5
+ class StateIl < LicenseValidator::Validations::Base
6
+ # @see super
7
+ def validate
8
+ super
9
+
10
+ return if driver.license_num.match?(/\A[a-z]\d{11}\z/i)
11
+
12
+ errors.add(:license_num, 'License number requires 1 alphabetic and 11 numeric for IL.')
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseValidator
4
+ module Validations
5
+ class StateIn < LicenseValidator::Validations::Base
6
+ # @see super
7
+ def validate
8
+ super
9
+
10
+ return if driver.license_num.match?(/\A\d{10}\z/i)
11
+
12
+ errors.add(:license_num, 'License number requires 10 numeric digits for IN.')
13
+ end
14
+ end
15
+ end
16
+ end