ssn_validation 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ssn_validation/ssn.rb +4 -1
- data/lib/version.rb +1 -1
- data/test/lib/ssn_validation/ssn_test.rb +8 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99078e971bb3179f2be8bceba90e15a8c1d5e677b261842fc69c186ed719b911
|
4
|
+
data.tar.gz: 338653e34b96bca231a163e26a93f8b21082d181058bb29ababd29e6b48a25d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8860e0abab51583c490e9dbb09d13c9503704ab166e2efdaa68c60025e8f4b1e32a86d065a07c6cc37b2a212cc8e78d9bd959f459d7be7e6f2e45fa7348a170
|
7
|
+
data.tar.gz: ef83571efab466ac22109ab543692195bac102a11bd7bf89b8b9eaa2c00e764d46de62e5fba191f6ef88c7be3e931271821c5e7457b1cfb00e4408584caf8c00
|
data/lib/ssn_validation/ssn.rb
CHANGED
@@ -2,6 +2,7 @@ module SsnValidation
|
|
2
2
|
module Ssn
|
3
3
|
DIGITS = %w[0 1 2 3 4 5 6 7 8 9].freeze
|
4
4
|
DIGITS_EX0 = DIGITS[1..-1]
|
5
|
+
VALID_ITIN_GROUPS = [50..65, 70..88, 90..92, 94..99].map(&:to_a).flatten.freeze
|
5
6
|
|
6
7
|
# returns a hash of 0..n key/value pairs for ssn validation error codes and a default message for each
|
7
8
|
def self.validate(ssn)
|
@@ -50,7 +51,9 @@ module SsnValidation
|
|
50
51
|
end
|
51
52
|
|
52
53
|
def self.invalid_itin?(ssn)
|
53
|
-
ssn[0] == "9"
|
54
|
+
return false unless ssn[0] == "9"
|
55
|
+
group = ssn[3..4].to_i
|
56
|
+
!VALID_ITIN_GROUPS.include?(group)
|
54
57
|
end
|
55
58
|
|
56
59
|
def self.test_ssn?(ssn)
|
data/lib/version.rb
CHANGED
@@ -8,6 +8,12 @@ class SsnTest < Minitest::Test
|
|
8
8
|
describe 'valid ITIN' do
|
9
9
|
it 'is valid' do
|
10
10
|
assert_equal({}, Ssn.validate('911781111'))
|
11
|
+
assert_equal({}, Ssn.validate('911501111'))
|
12
|
+
assert_equal({}, Ssn.validate('911651111'))
|
13
|
+
assert_equal({}, Ssn.validate('911651111'))
|
14
|
+
assert_equal({}, Ssn.validate('911881111'))
|
15
|
+
assert_equal({}, Ssn.validate('911901111'))
|
16
|
+
assert_equal({}, Ssn.validate('911991111'))
|
11
17
|
end
|
12
18
|
end
|
13
19
|
describe 'valid SSN' do
|
@@ -59,7 +65,8 @@ class SsnTest < Minitest::Test
|
|
59
65
|
end
|
60
66
|
describe 'invalid ITIN' do
|
61
67
|
it 'is invalid' do
|
62
|
-
assert_equal({invalid_itin: 'SSN value contains invalid ITIN format 9xx-[x]x-xxxx'}, Ssn.validate('
|
68
|
+
assert_equal({invalid_itin: 'SSN value contains invalid ITIN format 9xx-[x]x-xxxx'}, Ssn.validate('900121234'))
|
69
|
+
assert_equal({invalid_itin: 'SSN value contains invalid ITIN format 9xx-[x]x-xxxx'}, Ssn.validate('900441234'))
|
63
70
|
end
|
64
71
|
end
|
65
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ssn_validation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Stewart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|