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.
- checksums.yaml +4 -4
- data/lib/license-validator.rb +114 -0
- data/lib/license_validator/driver.rb +67 -0
- data/lib/license_validator/states.rb +14 -0
- data/lib/license_validator/validations/base.rb +62 -0
- data/lib/license_validator/validations/state_ak.rb +24 -0
- data/lib/license_validator/validations/state_al.rb +26 -0
- data/lib/license_validator/validations/state_ar.rb +20 -0
- data/lib/license_validator/validations/state_az.rb +31 -0
- data/lib/license_validator/validations/state_ca.rb +20 -0
- data/lib/license_validator/validations/state_co.rb +23 -0
- data/lib/license_validator/validations/state_ct.rb +39 -0
- data/lib/license_validator/validations/state_dc.rb +24 -0
- data/lib/license_validator/validations/state_de.rb +16 -0
- data/lib/license_validator/validations/state_fl.rb +16 -0
- data/lib/license_validator/validations/state_ga.rb +28 -0
- data/lib/license_validator/validations/state_hi.rb +27 -0
- data/lib/license_validator/validations/state_ia.rb +22 -0
- data/lib/license_validator/validations/state_id.rb +27 -0
- data/lib/license_validator/validations/state_il.rb +16 -0
- data/lib/license_validator/validations/state_in.rb +16 -0
- data/lib/license_validator/validations/state_ks.rb +24 -0
- data/lib/license_validator/validations/state_ky.rb +19 -0
- data/lib/license_validator/validations/state_la.rb +16 -0
- data/lib/license_validator/validations/state_ma.rb +22 -0
- data/lib/license_validator/validations/state_md.rb +22 -0
- data/lib/license_validator/validations/state_me.rb +16 -0
- data/lib/license_validator/validations/state_mi.rb +16 -0
- data/lib/license_validator/validations/state_mn.rb +16 -0
- data/lib/license_validator/validations/state_mo.rb +28 -0
- data/lib/license_validator/validations/state_ms.rb +16 -0
- data/lib/license_validator/validations/state_mt.rb +39 -0
- data/lib/license_validator/validations/state_nc.rb +24 -0
- data/lib/license_validator/validations/state_nd.rb +19 -0
- data/lib/license_validator/validations/state_ne.rb +16 -0
- data/lib/license_validator/validations/state_nh.rb +30 -0
- data/lib/license_validator/validations/state_nj.rb +16 -0
- data/lib/license_validator/validations/state_nm.rb +16 -0
- data/lib/license_validator/validations/state_nv.rb +21 -0
- data/lib/license_validator/validations/state_ny.rb +28 -0
- data/lib/license_validator/validations/state_oh.rb +19 -0
- data/lib/license_validator/validations/state_ok.rb +20 -0
- data/lib/license_validator/validations/state_or.rb +24 -0
- data/lib/license_validator/validations/state_pa.rb +20 -0
- data/lib/license_validator/validations/state_ri.rb +19 -0
- data/lib/license_validator/validations/state_sc.rb +16 -0
- data/lib/license_validator/validations/state_sd.rb +19 -0
- data/lib/license_validator/validations/state_tn.rb +20 -0
- data/lib/license_validator/validations/state_tx.rb +24 -0
- data/lib/license_validator/validations/state_ut.rb +16 -0
- data/lib/license_validator/validations/state_va.rb +16 -0
- data/lib/license_validator/validations/state_vt.rb +16 -0
- data/lib/license_validator/validations/state_wa.rb +23 -0
- data/lib/license_validator/validations/state_wi.rb +16 -0
- data/lib/license_validator/validations/state_wv.rb +26 -0
- data/lib/license_validator/validations/state_wy.rb +16 -0
- data/lib/license_validator/validators.rb +5 -0
- data/lib/license_validator/version.rb +1 -1
- metadata +87 -4
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateKs < 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 KS.')
|
12
|
+
end
|
13
|
+
|
14
|
+
lic_num = driver.license_num
|
15
|
+
|
16
|
+
return if lic_num.match?(/\AK\d{8}\z/i)
|
17
|
+
return if lic_num.match?(/\A[0-9a-z]{6}\z/i)
|
18
|
+
return if lic_num.match?(/\A\d{9}\z/i)
|
19
|
+
|
20
|
+
errors.add(:license_num, 'License number requires “K” and 8 Numeric, 6 Alphanumeric, or 9 numeric for KS.')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateKy < 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[a-z]\d{8}\z/i)
|
13
|
+
return if lic_num.match?(/\A\d{9}\z/i)
|
14
|
+
|
15
|
+
errors.add(:license_num, 'License number requires 1 alphabetic and 8 numeric, or 9 numeric for KY.')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateLa < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
return if driver.license_num.match?(/\A\d{9}\z/i)
|
11
|
+
|
12
|
+
errors.add(:license_num, 'License number requires 9 numeric digits for LA.')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateMa < 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[b-z]\d{8}\z/i)
|
13
|
+
return if lic_num.match?(/\A[a-z]{2}\d{7}\z/i) && !lic_num.match?(/\Afr\d{7}\z/i)
|
14
|
+
|
15
|
+
errors.add(
|
16
|
+
:license_num,
|
17
|
+
'License number requires 1 Alphabetic (B-Z), 8 Numeric or 2 Alphabetic (excluding FR), 7 Numeric for MA.'
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateMd < 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[a-z]\d{12}\z/i)
|
13
|
+
return if lic_num.match?(/\A[a-z]{2}\d{11}\z/i)
|
14
|
+
|
15
|
+
errors.add(
|
16
|
+
:license_num,
|
17
|
+
'License number requires 1 alphabetic and 12 numeric or 2 alphabetic and 11 numeric for MD.'
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateMe < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
return if driver.license_num.match?(/\A\d{7}\z/i)
|
11
|
+
|
12
|
+
errors.add(:license_num, 'License number requires 7 numeric digits for ME.')
|
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 StateMi < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
return if driver.license_num.match?(/\A[a-z]\d{12}\z/i)
|
11
|
+
|
12
|
+
errors.add(:license_num, 'License number requires 1 alphabetic and 12 numeric digits for MI.')
|
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 StateMn < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
return if driver.license_num.match?(/\A[a-z]\d{12}\z/i)
|
11
|
+
|
12
|
+
errors.add(:license_num, 'License number requires 1 alphabetic and 12 numeric digits for MN.')
|
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 StateMo < 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]\d{6}\z/i)
|
13
|
+
return if lic_num.match?(/\A[a-z]\d{5,9}\z/i)
|
14
|
+
return if lic_num.match?(/\A\d{9}[a-z]?\z/i)
|
15
|
+
return if lic_num.match?(/\A[a-z]\d{8}MA\z/i)
|
16
|
+
return if lic_num.match?(/\A\d{15}\z/i)
|
17
|
+
|
18
|
+
errors.add(
|
19
|
+
:license_num,
|
20
|
+
[
|
21
|
+
'License number requires 3 numeric, 1 alphabetic, 6 numeric or 1 Alphabetic, 5-9 Numeric or 9 Numeric or',
|
22
|
+
'1 Alphabetic, 8 Numeric, 2 Alphabetic “MA” or 9 Numeric, 1 Alphabetic, or 15 Numeric for MO.'
|
23
|
+
].join(' ')
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateMs < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
return if driver.license_num.match?(/\A\d{9}\z/i)
|
11
|
+
|
12
|
+
errors.add(:license_num, 'License number requires 9 numeric digits for MS.')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateMt < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
if driver.first_name.blank?
|
11
|
+
errors.add(:first_name, 'First name required for MT.')
|
12
|
+
end
|
13
|
+
|
14
|
+
if driver.last_name.blank?
|
15
|
+
errors.add(:last_name, 'Last name required for MT.')
|
16
|
+
end
|
17
|
+
|
18
|
+
if driver.dob.blank?
|
19
|
+
errors.add(:dbo, 'D.O.B. required for MT.')
|
20
|
+
end
|
21
|
+
|
22
|
+
lic_num = driver.license_num
|
23
|
+
|
24
|
+
return if lic_num.match?(/\A[a-z]\d[0-9a-z]\d{2}[a-z]{3}\d\z/i)
|
25
|
+
return if lic_num.match?(/\A\d{13}\z/i)
|
26
|
+
return if lic_num.match?(/\A[a-z]{3}\d{10}\z/i)
|
27
|
+
return if lic_num.match?(/\A\d{9}\z/i)
|
28
|
+
|
29
|
+
errors.add(
|
30
|
+
:license_num,
|
31
|
+
[
|
32
|
+
'License number requires 1 Alpha, 1 numeric, 1 alphanumeric, 2 numeric, 3 alpha, 1 numeric or 13 Numeric',
|
33
|
+
'or 3 Alpha, 10 Numeric or 9 Numeric for MT.'
|
34
|
+
].join(' ')
|
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 StateNc < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
unless driver.license_num.match?(/\A\d{1,12}\z/i)
|
11
|
+
errors.add(:license_num, 'License number requires 1-12 numbers for NC.')
|
12
|
+
end
|
13
|
+
|
14
|
+
if driver.last_name.blank?
|
15
|
+
errors.add(:last_name, 'Last name required for NC.')
|
16
|
+
end
|
17
|
+
|
18
|
+
return if driver.dob.present?
|
19
|
+
|
20
|
+
errors.add(:dob, 'D.O.B. required for NC.')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateNd < 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{9}\z/i)
|
13
|
+
return if lic_num.match?(/\A[a-z]{3}\d{6}\z/i)
|
14
|
+
|
15
|
+
errors.add(:license_num, 'License number reuqires 9 Numeric or 3 Alphabetic, 6 Numeric for ND.')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateNe < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
return if driver.license_num.match?(/\A[abceghprvz]\d{8}\z/i)
|
11
|
+
|
12
|
+
errors.add(:license_num, 'License number requires 1 Alphabetic (A,B,C,E,G,H,P,R,V or Z), 8 Numeric for NE.')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateNh < 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 NH.')
|
12
|
+
end
|
13
|
+
|
14
|
+
if driver.dob.blank?
|
15
|
+
errors.add(:dob, 'D.O.B. required for NH.')
|
16
|
+
end
|
17
|
+
|
18
|
+
lic_num = driver.license_num
|
19
|
+
|
20
|
+
return if lic_num.match?(/\A\d{2}[a-z]{3}\d{5}\z/i)
|
21
|
+
return if lic_num.match?(/\ANHL\d{8}\z/i)
|
22
|
+
|
23
|
+
errors.add(
|
24
|
+
:license_num,
|
25
|
+
'License number requires 2 Numeric, 3 Alphabetic, 5 Numeric or “NHL”, 8 Numeric for NH.'
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateNj < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
return if driver.license_num.match?(/\A[a-z]\d{14}\z/i)
|
11
|
+
|
12
|
+
errors.add(:license_num, 'License number requires 1 letter and 14 numbers for NJ.')
|
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 StateNm < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
return if driver.license_num.match?(/\A\d{9}\z/i)
|
11
|
+
|
12
|
+
errors.add(:license_num, 'License number requires 9 numbers for NM.')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateNv < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
dob_year = driver.dob.present? ? driver.dob.strftime('%y') : nil
|
11
|
+
|
12
|
+
regex = Regexp.new("\\A\\d{10}(#{dob_year})?\\z", 'i')
|
13
|
+
|
14
|
+
# 12 Numeric (last 2 are year of birth) or 10 numeric
|
15
|
+
return if driver.license_num.match?(regex)
|
16
|
+
|
17
|
+
errors.add(:license_num, 'License number requires 12 Numeric (last 2 are year of birth) or 10 numeric for NV.')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateNy < 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{8,9}\z/i)
|
13
|
+
return if lic_num.match?(/\A[a-z]\d{7}\z/i)
|
14
|
+
return if lic_num.match?(/\A[a-z]{8}\z/i)
|
15
|
+
return if lic_num.match?(/\A\d{16}\z/i)
|
16
|
+
return if lic_num.match?(/\A[a-z]\d{18}\z/i)
|
17
|
+
|
18
|
+
errors.add(
|
19
|
+
:license_num,
|
20
|
+
[
|
21
|
+
'License number requires 9 Numeric or 8 Numeric or 1 Alphabetic, 7 Numeric or 16 Numeric or 8 Alphabetic',
|
22
|
+
'or 1 Alphabetic, 18 Numeric (not being issued anymore) for NY.'
|
23
|
+
].join(' ')
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateOh < 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[a-z]{2}\d{6}\z/i)
|
13
|
+
return if lic_num.match?(/\A\d{9}\z/i)
|
14
|
+
|
15
|
+
errors.add(:license_num, 'License number requires 2 Alphabetic, 6 Numeric or 9 Numeric for OH.')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateOk < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
unless driver.license_num.match?(/\A[a-z]?\d{9}\z/i)
|
11
|
+
errors.add(:license_num, 'License number requires 1 letter (optional) followed by 9 numbers for OK.')
|
12
|
+
end
|
13
|
+
|
14
|
+
return if driver.dob.present?
|
15
|
+
|
16
|
+
errors.add(:dob, 'D.O.B. required for OK.')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateOr < 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 OR.')
|
12
|
+
end
|
13
|
+
|
14
|
+
license = driver.license_num
|
15
|
+
|
16
|
+
return if license.match?(/\A\d{9}\z/i)
|
17
|
+
return if license.match?(/\A[a-z]\d{6}\z/i)
|
18
|
+
return if license.match?(/\A\d{7}\z/i)
|
19
|
+
|
20
|
+
errors.add(:license_num, 'License number requires 9 Numeric or 1 Alpha, 6 numeric, or 7 numeric for OR.')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StatePa < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
unless driver.license_num.match?(/\A\d{8}\z/i)
|
11
|
+
errors.add(:license_num, 'License number requires 8 numbers for PA.')
|
12
|
+
end
|
13
|
+
|
14
|
+
return if driver.last_name.present?
|
15
|
+
|
16
|
+
errors.add(:last_name, 'Last name required for PA.')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateRi < 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?(/\AV\d{6}\z/i)
|
14
|
+
|
15
|
+
errors.add(:license_num, 'License number requires 8 numeric or 7 Numeric or V and 6 Numeric for RI.')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateSc < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
return if driver.license_num.match?(/\A\d{1,9}\z/i)
|
11
|
+
|
12
|
+
errors.add(:license_num, 'License number requires 1-9 numbers for SC.')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateSd < 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{6}\z/i)
|
13
|
+
return if lic_num.match?(/\A\d{8,9}\z/i)
|
14
|
+
|
15
|
+
errors.add(:license_num, 'License number requires 6,8, or 9 numbers for SD.')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateTn < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
unless driver.license_num.match?(/\A\d{7,9}\z/i)
|
11
|
+
errors.add(:license_num, 'License number requires 7-9 numbers for TN.')
|
12
|
+
end
|
13
|
+
|
14
|
+
return if driver.last_name.present?
|
15
|
+
|
16
|
+
errors.add(:last_name, 'Last name required for TN.')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseValidator
|
4
|
+
module Validations
|
5
|
+
class StateTx < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
unless driver.license_num.match?(/\A[01234]\d{7}\z/i)
|
11
|
+
errors.add(:license_num, 'License number requires a 0,1,2,3, or 4 to start and 7 more numbers for TX.')
|
12
|
+
end
|
13
|
+
|
14
|
+
if driver.last_name.blank?
|
15
|
+
errors.add(:last_name, 'Last name required for TX.')
|
16
|
+
end
|
17
|
+
|
18
|
+
return if driver.dob.present?
|
19
|
+
|
20
|
+
errors.add(:dob, 'D.O.B. is required for TX.')
|
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 StateUt < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
return if driver.license_num.match?(/\A\d{4,10}\z/i)
|
11
|
+
|
12
|
+
errors.add(:license_num, 'License number requires 4-10 numbers for UT.')
|
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 StateVa < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
return if driver.license_num.match?(/\A[a-z\d]\d{8}\z/i)
|
11
|
+
|
12
|
+
errors.add(:license_num, 'License number requires a letter or number followed by 8 numbers for VA.')
|
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 StateVt < LicenseValidator::Validations::Base
|
6
|
+
# @see super
|
7
|
+
def validate
|
8
|
+
super
|
9
|
+
|
10
|
+
return if driver.license_num.match?(/\A\d{7}[0-9a]\z/i)
|
11
|
+
|
12
|
+
errors.add(:license_num, 'License number requires 7 number followed by an A or 1 more number for VT.')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|