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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cff944596627e765443786de2ce3ed67c257a348eb516ba002ade8d0adffc5cf
4
- data.tar.gz: 636d1c1ce54b93c06a6d4d6ed3a66f09c067f856a216700df4a20ecda869f705
3
+ metadata.gz: 99078e971bb3179f2be8bceba90e15a8c1d5e677b261842fc69c186ed719b911
4
+ data.tar.gz: 338653e34b96bca231a163e26a93f8b21082d181058bb29ababd29e6b48a25d2
5
5
  SHA512:
6
- metadata.gz: 73e9389c9c5e3b812019084d4dd1a4523712b0684a4c85cc2d59895046d6b24eaa99fb9f43fb36881fee827ec594e36af87b0e131a7eb7ca306fdbdfdd9461b1
7
- data.tar.gz: 66ed232ac6c6dc0c1ff3b45b43a6f8c3fa204d8880279a7daeb3d12fb29e1c4af9d7d9fa68376fc1229e04d16df2840e48b9b7956dfec1a7da35588bcd56fe6d
6
+ metadata.gz: e8860e0abab51583c490e9dbb09d13c9503704ab166e2efdaa68c60025e8f4b1e32a86d065a07c6cc37b2a212cc8e78d9bd959f459d7be7e6f2e45fa7348a170
7
+ data.tar.gz: ef83571efab466ac22109ab543692195bac102a11bd7bf89b8b9eaa2c00e764d46de62e5fba191f6ef88c7be3e931271821c5e7457b1cfb00e4408584caf8c00
@@ -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" && !%w[7 8].include?(ssn[3])
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)
@@ -1,3 +1,3 @@
1
1
  module SsnValidation
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
@@ -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('900991234'))
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
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-09 00:00:00.000000000 Z
11
+ date: 2019-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake