dl_validator 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +10 -1
- data/lib/dl_validator.rb +5 -0
- data/lib/dl_validator/version.rb +1 -1
- data/test/test_dl_validator.rb +26 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d842ca8ae1d8e0f2744ee451eb65c78378ec9d2d
|
4
|
+
data.tar.gz: 2818a638b67f8f4fc45c9e88935014fe124cd38f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2ab27d739aa15de609f74df9a88237cde4f0a2a5afa41e65e63a08590a33c709f60f2065a0e6cadf29b47699d8fb61f57c0fcebd4301f83b977839d8b6fa3f4
|
7
|
+
data.tar.gz: 7f7009fefb7f0210d372543d3da82f61ffb4ed8c231799e1958f6b3b683a360a3914a79a64b7256881e58099772fe7ef17fe61afba9a57ab19fab79fdc0ff5ff
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
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
4
|
|
5
|
+
The valid method is supported in version >= 0.0.5
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
@@ -22,7 +24,10 @@ With a drivers license number and drivers license state
|
|
22
24
|
|
23
25
|
```ruby
|
24
26
|
DlValidator.invalid?('F123456789012', 'FL') => false
|
25
|
-
DlValidator.invalid?('F7834', 'FL')
|
27
|
+
DlValidator.invalid?('F7834', 'FL') => true
|
28
|
+
|
29
|
+
DlValidator.valid?('F123456789012', 'FL') => true
|
30
|
+
DlValidator.valid?('F7834', 'FL') => false
|
26
31
|
```
|
27
32
|
|
28
33
|
Inside your rails model. Dependent on fields :drivers_license_number and :drivers_license_state
|
@@ -41,3 +46,7 @@ end
|
|
41
46
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
47
|
4. Push to the branch (`git push origin my-new-feature`)
|
43
48
|
5. Create new Pull Request
|
49
|
+
|
50
|
+
## Future
|
51
|
+
|
52
|
+
Update active model validation to be more flexible with field names.
|
data/lib/dl_validator.rb
CHANGED
data/lib/dl_validator/version.rb
CHANGED
data/test/test_dl_validator.rb
CHANGED
@@ -2,20 +2,20 @@ require File.expand_path(File.dirname(__FILE__) + '/test_helper')
|
|
2
2
|
|
3
3
|
class DlValidatorTest < Test::Unit::TestCase
|
4
4
|
context DlValidator do
|
5
|
-
context '
|
5
|
+
context '.invalid?' do
|
6
6
|
|
7
|
-
Helper::VALID_DRIVERS_LICENSES.each do |
|
7
|
+
Helper::VALID_DRIVERS_LICENSES.each do |state, licenses_array|
|
8
8
|
licenses_array.each_with_index do |license, index|
|
9
|
-
should "be a valid drivers license #{license} - #{
|
10
|
-
assert !DlValidator.invalid?(license,
|
9
|
+
should "be a valid drivers license #{license} - #{state} index: #{index}" do
|
10
|
+
assert !DlValidator.invalid?(license, state), state.inspect + ' ' + license.inspect
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
Helper::VALID_DRIVERS_LICENSES.each do |
|
15
|
+
Helper::VALID_DRIVERS_LICENSES.each do |state, licenses_array|
|
16
16
|
licenses_array.each_with_index do |license, index|
|
17
|
-
should "not be a valid drivers license #{license} - #{
|
18
|
-
assert DlValidator.invalid?(license + '123ABC',
|
17
|
+
should "not be a valid drivers license #{license} - #{state} index: #{index}" do
|
18
|
+
assert DlValidator.invalid?(license + '123ABC', state), state.inspect + ' ' + license + '123ABC'
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -54,12 +54,30 @@ class DlValidatorTest < Test::Unit::TestCase
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
context '
|
57
|
+
context '.get_abbreviation_key' do
|
58
58
|
DlValidator::DlConfig::STATES.each do |state_abbreviation, state_name|
|
59
59
|
should "return the correct state abbreviation #{state_abbreviation}" do
|
60
60
|
assert_equal state_abbreviation, DlValidator.get_abbreviation_key(state_name)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
64
|
+
|
65
|
+
context '.valid' do
|
66
|
+
Helper::VALID_DRIVERS_LICENSES.each do |state, licenses_array|
|
67
|
+
licenses_array.each_with_index do |license, index|
|
68
|
+
should "be a valid drivers license #{license} - #{state} index: #{index}" do
|
69
|
+
assert DlValidator.valid?(license, state), state.inspect + ' ' + license.inspect
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
Helper::VALID_DRIVERS_LICENSES.each do |state, licenses_array|
|
75
|
+
licenses_array.each_with_index do |license, index|
|
76
|
+
should "not be a valid drivers license #{license} - #{state} index: #{index}" do
|
77
|
+
refute DlValidator.valid?(license + '123ABC', state), state.inspect + ' ' + license + '123ABC'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
64
82
|
end
|
65
83
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dl_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Medeiros
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|