dl_validator 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1c05229f64b822fccb05d6bde7ee27eab8bb9174
4
+ data.tar.gz: d40fe53c6d599829a8efba5456b853bfba5854fb
5
+ SHA512:
6
+ metadata.gz: 0ad7df42dd1b12b1d5bf82b5a4bf773cffd49ebec00eed152608c5e926b834af5053b752e3c483ed0c589b18dfce70576664ab1e8aa8b3a22073a54505f0a1a4
7
+ data.tar.gz: 9fc7b0dabe5031269375451e2516ef8f8e4f14f4b8ddfe30698664512ea46357fa8bc25f9260da6307f6a88d8dfd6dcdaacdca477dd37fc97cfe63ab5e64ed1e
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .ruby-gemset
7
+ .ruby-version
8
+ .idea
9
+ pkg/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dl_validator.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,37 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dl_validator (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (4.0.0)
10
+ i18n (~> 0.6, >= 0.6.4)
11
+ minitest (~> 4.2)
12
+ multi_json (~> 1.3)
13
+ thread_safe (~> 0.1)
14
+ tzinfo (~> 0.3.37)
15
+ atomic (1.1.10)
16
+ i18n (0.6.4)
17
+ minitest (4.3.2)
18
+ multi_json (1.7.7)
19
+ rake (10.0.4)
20
+ shoulda (3.5.0)
21
+ shoulda-context (~> 1.0, >= 1.0.1)
22
+ shoulda-matchers (>= 1.4.1, < 3.0)
23
+ shoulda-context (1.1.4)
24
+ shoulda-matchers (2.2.0)
25
+ activesupport (>= 3.0.0)
26
+ thread_safe (0.1.0)
27
+ atomic
28
+ tzinfo (0.3.37)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ bundler (~> 1.3)
35
+ dl_validator!
36
+ rake
37
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Andrew Medeiros
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # DlValidator
2
+
3
+ DlValidator is a small gem that performs soft checks against a drivers license number and state. This is used only to flag a drivers license as being invalid, and is not intended to be considered true denial on a drivers license number.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'dl_validator'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install dl_validator
18
+
19
+ ## Usage
20
+
21
+ With a drivers license number and drivers license state
22
+
23
+ ```ruby
24
+ DlValidator.invalid?('F123456789012', 'FL') => false
25
+ DlValidator.invalid?('F7834', 'FL') => true
26
+ ```
27
+
28
+ Inside your rails model. Dependent on fields :drivers_license_number and :drivers_license_state
29
+ ```ruby
30
+ class DriversLicense < ActiveRecord::Base
31
+ attr_accessible :drivers_license_number, :drivers_license_state
32
+ validates :drivers_license_number, :drivers_license_state, :drivers_license_invalid => true
33
+ end
34
+ ```
35
+
36
+
37
+ ## Contributing
38
+
39
+ 1. Fork it
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |task|
5
+ task.libs << 'test'
6
+ end
7
+
8
+ task :default => [:test]
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dl_validator/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'dl_validator'
8
+ spec.version = DlValidator::VERSION
9
+ spec.authors = ['Andrew Medeiros']
10
+ spec.email = ['amedeiros0920@gmail.com']
11
+ spec.description = %q{DlValidator is a small gem that performs soft checks against a drivers license number and state. This is used only to flag a drivers license as being invalid, and is not intended to be considered true denial on a drivers license number.}
12
+ spec.summary = %q{DlValidator is a small gem that performs soft checks against a drivers license number and state. This is used only to flag a drivers license as being invalid, and is not intended to be considered true denial on a drivers license number.}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'shoulda'
24
+ end
@@ -0,0 +1,113 @@
1
+ module DlValidator
2
+ class Config
3
+ # Constant frozen hash of states and abbreviations
4
+ STATES = {
5
+ 'AL' => 'ALABAMA',
6
+ 'AK' => 'ALASKA',
7
+ 'AZ' => 'ARIZONA',
8
+ 'AR' => 'ARKANSAS',
9
+ 'CA' => 'CALIFORNIA',
10
+ 'CO' => 'COLORADO',
11
+ 'CT' => 'CONNECTICUT',
12
+ 'DE' => 'DELAWARE',
13
+ 'DC' => 'DISTRICT OF COLUMBIA',
14
+ 'FL' => 'FLORIDA',
15
+ 'GA' => 'GEORGIA',
16
+ 'HI' => 'HAWAII',
17
+ 'ID' => 'IDAHO',
18
+ 'IL' => 'ILLINOIS',
19
+ 'IN' => 'INDIANA',
20
+ 'IA' => 'IOWA',
21
+ 'KS' => 'KANSAS',
22
+ 'KY' => 'KENTUCKY',
23
+ 'LA' => 'LOUISIANA',
24
+ 'ME' => 'MAINE',
25
+ 'MD' => 'MARYLAND',
26
+ 'MA' => 'MASSACHUSETTS',
27
+ 'MI' => 'MICHIGAN',
28
+ 'MN' => 'MINNESOTA',
29
+ 'MS' => 'MISSISSIPPI',
30
+ 'MO' => 'MISSOURI',
31
+ 'MT' => 'MONTANA',
32
+ 'NE' => 'NEBRASKA',
33
+ 'NV' => 'NEVADA',
34
+ 'NH' => 'NEW HAMPSHIRE',
35
+ 'NJ' => 'NEW JERSEY',
36
+ 'NY' => 'NEW YORK',
37
+ 'NM' => 'NEW MEXICO',
38
+ 'NC' => 'NORTH CAROLINA',
39
+ 'ND' => 'NORTH DAKOTA',
40
+ 'OH' => 'OHIO',
41
+ 'OK' => 'OKLAHOMA',
42
+ 'OR' => 'OREGON',
43
+ 'PA' => 'PENNSYLVANIA',
44
+ 'RI' => 'RHODE ISLAND',
45
+ 'SC' => 'SOUTH CAROLINA',
46
+ 'SD' => 'SOUTH DAKOTA',
47
+ 'TN' => 'TENNESSEE',
48
+ 'TX' => 'TEXAS',
49
+ 'UT' => 'UTAH',
50
+ 'VT' => 'VERMONT',
51
+ 'VA' => 'VIRGINIA',
52
+ 'WA' => 'WASHINGTON',
53
+ 'WV' => 'WEST VIRGINIA',
54
+ 'WI' => 'WISCONSIN',
55
+ 'WY' => 'WYOMING' }.freeze
56
+
57
+
58
+
59
+ # Constant frozen hash of regular expressions to validate a drivers license by state
60
+ STATES_REGEX = {
61
+ 'AL' => /^([0-9]{7})$/, # Format: 7 numeric
62
+ 'AK' => /^([0-9]{7})$/, # Format: 7 numeric
63
+ 'AZ' => /^([A-Z][0-9]{8})$/, # Format: 1 Alpha 8 numeric
64
+ 'AR' => /^([0-9]{8})$/, # Format: 8 Numeric
65
+ 'CA' => /^([A-Z][0-9]{7})$/, # Format: 1 Alpha 7 Numeric
66
+ 'CO' => /^([0-9]{9})$/, # Format: 9 Numeric
67
+ 'CT' => /^((01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24)[0-9]{7})$/, # Format: 9 Numeric; The first 2 digits can not be less than 01 or greater than 24.
68
+ 'DE' => /^([0-9]{7})$/, # Format: 7 Numeric
69
+ 'DC' => /^([0-9]{7})$/, # Format: 7 Numeric
70
+ 'FL' => /^([A-Z][0-9]{12})$/, # Format: 1 Alpha 12 Numeric
71
+ 'GA' => /^([0-9]{7,9})$/, # Format: 7-9 Numeric
72
+ 'HI' => /^([H][0-9]{8})$/, # Format: H followed by 8 numeric
73
+ 'ID' => /^([A-Z]{2}[0-9]{6}[A-Z])$/, # Format: 2 Alpha 6 Numeric 1 Alpha (example LS123456C)
74
+ 'IL' => /^([A-Z][0-9]{11})$/, # Format: 1 alpha 11 numeric
75
+ 'IN' => /^([0-9]{10})$/, # Format: 10 Numeric
76
+ 'IA' => /^([0-9]{3}[A-Z]{2}[0-9]{4})$/, # Format: 3 Numeric 2 Alpha 4 Numeric (example 123SL4567)
77
+ 'KS' => /^([A-Z][0-9]{8})$/, # Format: 1 Alpha 8 Numeric
78
+ 'KY' => /^([A-Z][0-9]{8})$/, # Format: 1 Alpha 8 Numeric
79
+ 'LA' => /^((00|01)[0-9]{7})$/, # Format: 9 Numeric (First two numbers are 00 or 01)
80
+ 'ME' => /^([0-9]{7})$/, # Format: 7 Numeric
81
+ 'MD' => /^([A-Z][0-9]{12})$/, # Format: 1 Alpha 12 Numeric
82
+ 'MA' => /^([A-Z][0-9]{8})$/, # Format: 1 Alpha 8 Numeric
83
+ 'MI' => /^([A-Z][0-9]{12})$/, # Format: 1 Alpha 12 Numeric
84
+ 'MN' => /^([A-Z][0-9]{12})$/, # Format: 1 Alpha 12 Numeric
85
+ 'MS' => /^([0-9]{9})$/, # Format: 9 Numeric
86
+ 'MO' => /^([A-Z][0-9]{5,9})$/, # Format: 1 Alpha 5-9 Numeric
87
+ 'MT' => /^(([A-Z]|[0-9]){9})$/, # Format: 9 Alpha And Numeric Combination
88
+ 'NE' => /^([A-Z][0-9]{3,8})$/, # Format: 1 Alpha 3-8 Numeric
89
+ 'NV' => /^([0-9]{10}|[0-9]{12}|[X][0-9]{8})$/, # Format: 10 Numeric; or 12 Numeric; or X Followed By 8 Numeric
90
+ 'NH' => /^([0-9]{2}[A-Z]{3}[0-9]{5})$/, # Format: 2 Numeric 3 Alpha 5 Numeric
91
+ 'NJ' => /^([A-Z][0-9]{14})$/, # Format: 1 Alpha 14 Numeric
92
+ 'NY' => /^([0-9]{9})$/, # Format: 9 Numeric
93
+ 'NM' => /^([0-9]{9})$/, # Format: 9 Numeric
94
+ 'NC' => /^([0-9]{6,9})$/, # Format: 6-9 Numeric
95
+ 'ND' => /^([0-9]{9})$/, # Format: 9 Numeric
96
+ 'OH' => /^([A-Z]{2}[0-9]{6})$/, # Format: 2 Alpha 6 Numeric
97
+ 'OK' => /^([0-9]{9})$/, # Format: 9 Numeric
98
+ 'OR' => /^([0-9]{5,7})$/, # Format: 5-7 Numeric
99
+ 'PA' => /^([0-9]{8})$/, # Format: 8 Numeric
100
+ 'RI' => /^([0-9]{7})$/, # Format: 7 Numeric
101
+ 'SC' => /^([0-9]{9})$/, # Format: 9 Numeric
102
+ 'SD' => /^([0-9]{8})$/, # Format: 8 Numeric
103
+ 'TN' => /^([0-9]{7}|[0-9]{8}|[0-9]{9})$/, # Format: 7,8 or 9 Numeric
104
+ 'TX' => /^([0-9]{8})$/, # Format: 8 Numeric
105
+ 'UT' => /^([0-9]{6,10})$/, # Format: 6-10 Numeric
106
+ 'VT' => /^([0-9]{8}|[0-9]{7}[A-Z])$/, # Format: 8 Numeric; or 7 Numeric 1 Alpha
107
+ 'VA' => /^([A-Z][0-9]{8})$/, # Format: 1 Alpha 8 Numeric
108
+ 'WA' => /^(([A-Z]|[0-9]){12})$/, # Format: 12 Alpha And Numeric Combination
109
+ 'WV' => /^([0-9]{7}|[A-Z][0-9]{6})$/, # Format: 7 Numeric; or 1 Alpha 6 Numeric
110
+ 'WI' => /^([A-Z][0-9]{13})$/, # Format: 1 Alpha 13 Numeric
111
+ 'WY' => /^([0-9]{9,10})$/ }.freeze # Format: 9-10 Numeric
112
+ end
113
+ end
@@ -0,0 +1,3 @@
1
+ module DlValidator
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,38 @@
1
+ require 'dl_validator/version'
2
+ require 'config/config'
3
+ require 'extensions/drivers_license_invalid_validator' if defined?(Rails)
4
+
5
+ module DlValidator
6
+ def self.invalid?(dl_number, dl_state)
7
+ # Stop and return true if either dl_number or dl_state are nil
8
+ return true if dl_number.nil? or dl_state.nil?
9
+
10
+ # Downcase and remove non-word characters
11
+ dl_number = dl_number.to_s.upcase.gsub(/(\W|_)*/, '')
12
+ dl_state = dl_state.to_s.upcase.gsub(/(\W|\d|_)*/, '')
13
+
14
+ # Stop here and return true if the state does not exist
15
+ return true if !Config::STATES.include?(dl_state) and !Config::STATES.values.include?(dl_state)
16
+
17
+ # Find the state abbreviation key we need to access our regex hash.
18
+ key = get_abbreviation_key(dl_state)
19
+
20
+ # Regular expression match to validate the drivers license is invalid or not
21
+ return false if Config::STATES_REGEX[key].match(dl_number)
22
+ true
23
+ end
24
+
25
+ # This is moved out into a method to make unit testing easier.
26
+ def self.get_abbreviation_key(dl_state)
27
+ # If the dl_state is greater than 2 then it is a full state name and we need to find the corresponding abbreviation for that state.
28
+ key = ''
29
+ if dl_state.length > 2
30
+ Config::STATES.each do |k, v|
31
+ key = k if v == dl_state
32
+ end
33
+ else
34
+ key = dl_state # The dl_state is already an abbreviated state
35
+ end
36
+ key
37
+ end
38
+ end
@@ -0,0 +1,17 @@
1
+ class DriversLicenseInvalidValidator < ActiveModel::Validator
2
+ def validate(record)
3
+ if !@options[:attributes].include?(:drivers_license_number)
4
+ record.errors.add(:base, 'Missing required attribute drivers_license_number')
5
+ elsif !@options[:attributes].include?(:drivers_license_state)
6
+ record.errors.add(:base, 'Missing required attribute drivers_license_state')
7
+ elsif record.drivers_license_number.blank?
8
+ record.errors.add(:drivers_license_number, 'cannot be blank.')
9
+ elsif record.drivers_license_state.blank?
10
+ record.errors.add(:drivers_license_state, 'cannot be blank.')
11
+ else
12
+ invalid = DlValidator.invalid?(record.drivers_license_number, record.drivers_license_state)
13
+ record.errors.add(:base, 'Drivers license is invalid.') if invalid
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,65 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/test_helper')
2
+
3
+ class DlValidatorTest < Test::Unit::TestCase
4
+ context DlValidator do
5
+ context '#invalid?' do
6
+
7
+ Helper::VALID_DRIVERS_LICENSES.each do |key, licenses_array|
8
+ licenses_array.each_with_index do |license, index|
9
+ should "be a valid drivers license #{license} - #{key} index: #{index}" do
10
+ assert !DlValidator.invalid?(license, key), key.inspect + ' ' + license.inspect
11
+ end
12
+ end
13
+ end
14
+
15
+ Helper::VALID_DRIVERS_LICENSES.each do |key, licenses_array|
16
+ licenses_array.each_with_index do |license, index|
17
+ should "not be a valid drivers license #{license} - #{key} index: #{index}" do
18
+ assert DlValidator.invalid?(license + '123ABC', key), key.inspect + ' ' + license + '123ABC'
19
+ end
20
+ end
21
+ end
22
+
23
+ should 'return true for an undefined state abbreviation' do
24
+ invalid = DlValidator.invalid?('123', 'QQ')
25
+ assert invalid
26
+ end
27
+
28
+ should 'return true for an undefined full state name' do
29
+ invalid = DlValidator.invalid?('123', 'BadState')
30
+ assert invalid
31
+ end
32
+
33
+ should 'handle a state abbreviation with non-word characters' do
34
+ state = '12}3 F (** __)L @ 5674``' # FL
35
+ assert !DlValidator.invalid?(Helper::VALID_DRIVERS_LICENSES['FL'].first, state)
36
+ end
37
+
38
+ should 'handle a full state name with non-word characters' do
39
+ state = '12_3 F (** )L o # R ^ I !!!! DA @ 907' # FLORIDA
40
+ assert !DlValidator.invalid?(Helper::VALID_DRIVERS_LICENSES['FL'].first, state)
41
+ end
42
+
43
+ should 'handle a state license with non-word characters' do
44
+ license = 'F / @!!()_-=123 45%$#67 898?.,;76' # F123456789876
45
+ assert !DlValidator.invalid?(license, 'FL')
46
+ end
47
+
48
+ should 'return true for a nil drivers_license_number' do
49
+ assert DlValidator.invalid?(drivers_license_number=nil, 'FL')
50
+ end
51
+
52
+ should 'return true for a nil drivers_license_state' do
53
+ assert DlValidator.invalid?('123456', drivers_license_state=nil)
54
+ end
55
+ end
56
+
57
+ context '#get_abbreviation_key' do
58
+ DlValidator::Config::STATES.each do |state_abbreviation, state_name|
59
+ should "return the correct state abbreviation #{state_abbreviation}" do
60
+ assert_equal state_abbreviation, DlValidator.get_abbreviation_key(state_name)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,59 @@
1
+ require 'test/unit'
2
+ require 'dl_validator'
3
+ require 'shoulda'
4
+
5
+ class Helper
6
+
7
+ VALID_DRIVERS_LICENSES = {
8
+ 'AL' => ['1234567'], # Format: 7 numeric
9
+ 'AK' => ['1234567'], # Format: 7 numeric
10
+ 'AZ' => ['A12345678'], # Format: 1 Alpha 8 numeric
11
+ 'AR' => ['12345678'], # Format: 8 Numeric
12
+ 'CA' => ['c1234567'], # Format: 1 Alpha 7 Numeric
13
+ 'CO' => ['123456789'], # Format: 9 Numeric
14
+ 'CT' => ['201234567', '241234567'], # Format: 9 Numeric; The first 2 digits can not be less than 01 or greater than 24.
15
+ 'DE' => ['1234567'], # Format: 7 Numeric
16
+ 'DC' => ['1234567'], # Format: 7 Numeric
17
+ 'FL' => ['F123456789876'], # Format: 1 Alpha 12 Numeric
18
+ 'GA' => ['1234567', '1234567', '123456789'], # Format: 7-9 Numeric
19
+ 'HI' => ['h12345678'], # Format: H followed by 8 numeric
20
+ 'ID' => ['LS123456C'], # Format: 2 Alpha 6 Numeric 1 Alpha (example LS123456C)
21
+ 'IL' => ['J12345678901'], # Format: 1 alpha 11 numeric
22
+ 'IN' => ['1234567890'], # Format: 10 Numeric
23
+ 'IA' => ['123SL4567'], # Format: 3 Numeric 2 Alpha 4 Numeric (example 123SL4567)
24
+ 'KS' => ['K12345678'], # Format: 1 Alpha 8 Numeric
25
+ 'KY' => ['Y12345678'], # Format: 1 Alpha 8 Numeric
26
+ 'LA' => ['001234567', '012345678'], # Format: 9 Numeric (First two numbers are 00 or 01)
27
+ 'ME' => ['1234567'], # Format: 7 Numeric
28
+ 'MD' => ['M123456789012'], # Format: 1 Alpha 12 Numeric
29
+ 'MA' => ['A12345678'], # Format: 1 Alpha 8 Numeric
30
+ 'MI' => ['h123456789012'], # Format: 1 Alpha 12 Numeric
31
+ 'MN' => ['L123456789012'], # Format: 1 Alpha 12 Numeric
32
+ 'MS' => ['123456789'], # Format: 9 Numeric
33
+ 'MO' => ['M12345678', 'M12345678' , 'M12345679'], # Format: 1 Alpha 5-9 Numeric
34
+ 'MT' => ['J9G4n6E8a'], # Format: 9 Alpha And Numeric Combination
35
+ 'NE' => ['A123', 'A1234', 'A12345', 'A123456', 'A1234567', 'A12345678'], # Format: 1 Alpha 3-8 Numeric
36
+ 'NV' => ['1234567890', '123456789123', 'X12345678'], # Format: 10 Numeric; or 12 Numeric; or X Followed By 8 Numeric
37
+ 'NH' => ['12ADF12345'], # Format: 2 Numeric 3 Alpha 5 Numeric
38
+ 'NJ' => ['F12345678901234'], # Format: 1 Alpha 14 Numeric
39
+ 'NY' => ['123456789'], # Format: 9 Numeric
40
+ 'NM' => ['123456789'], # Format: 9 Numeric
41
+ 'NC' => ['123456', '1234567', '12345678', '123456789'], # Format: 6-9 Numeric
42
+ 'ND' => ['123456789'], # Format: 9 Numeric
43
+ 'OH' => ['LK123456'], # Format: 2 Alpha 6 Numeric
44
+ 'OK' => ['123456789'], # Format: 9 Numeric
45
+ 'OR' => ['12345', '123456', '1234567'], # Format: 5-7 Numeric
46
+ 'PA' => ['12345678'], # Format: 8 Numeric
47
+ 'RI' => ['1234567'], # Format: 7 Numeric
48
+ 'SC' => ['123456789'], # Format: 9 Numeric
49
+ 'SD' => ['12345678'], # Format: 8 Numeric
50
+ 'TN' => ['1234567', '12345678', '123456789'], # Format: 7,8 or 9 Numeric
51
+ 'TX' => ['12345678'], # Format: 8 Numeric
52
+ 'UT' => ['123456', '1234567', '12345678', '123456789', '1234567890'], # Format: 6-10 Numeric
53
+ 'VT' => ['12345678', '1234567K'], # Format: 8 Numeric; or 7 Numeric 1 Alpha
54
+ 'VA' => ['K12345678'], # Format: 1 Alpha 8 Numeric
55
+ 'WA' => ['123ghk456QWE'], # Format: 12 Characters
56
+ 'WV' => ['1234567', 'E123456'], # Format: 7 Numeric; or 1 Alpha 6 Numeric
57
+ 'WI' => ['W1234567890123'], # Format: 1 Alpha 13 Numeric
58
+ 'WY' => ['123456789', '1234567890'] } # Format: 9-10 Numeric
59
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dl_validator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Medeiros
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: shoulda
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: DlValidator is a small gem that performs soft checks against a drivers
56
+ license number and state. This is used only to flag a drivers license as being invalid,
57
+ and is not intended to be considered true denial on a drivers license number.
58
+ email:
59
+ - amedeiros0920@gmail.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - .gitignore
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - dl_validator.gemspec
71
+ - lib/config/config.rb
72
+ - lib/dl_validator.rb
73
+ - lib/dl_validator/version.rb
74
+ - lib/extensions/drivers_license_invalid_validator.rb
75
+ - test/test_dl_validator.rb
76
+ - test/test_helper.rb
77
+ homepage: ''
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.0.3
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: DlValidator is a small gem that performs soft checks against a drivers license
101
+ number and state. This is used only to flag a drivers license as being invalid,
102
+ and is not intended to be considered true denial on a drivers license number.
103
+ test_files:
104
+ - test/test_dl_validator.rb
105
+ - test/test_helper.rb