ssn_validation 0.1.5 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99078e971bb3179f2be8bceba90e15a8c1d5e677b261842fc69c186ed719b911
4
- data.tar.gz: 338653e34b96bca231a163e26a93f8b21082d181058bb29ababd29e6b48a25d2
3
+ metadata.gz: 0feef3d1f27edb2f2ccd820dc2fb1663c860826c376f33e15f36b134c089a7e9
4
+ data.tar.gz: 33ad0dfc1f6cce507e48599cf5a4a1d67b8ffdac7c27431f5579b6d2f68122ee
5
5
  SHA512:
6
- metadata.gz: e8860e0abab51583c490e9dbb09d13c9503704ab166e2efdaa68c60025e8f4b1e32a86d065a07c6cc37b2a212cc8e78d9bd959f459d7be7e6f2e45fa7348a170
7
- data.tar.gz: ef83571efab466ac22109ab543692195bac102a11bd7bf89b8b9eaa2c00e764d46de62e5fba191f6ef88c7be3e931271821c5e7457b1cfb00e4408584caf8c00
6
+ metadata.gz: fdb7750c8a6600fb576c9ae9ac0f6712e4b7b7c9fc52b4d0e1615fe5cadc72f5ca4c70f544dab0c5070bad228724ad21154ac08ae81059fe70b9c17d93acae22
7
+ data.tar.gz: c7cccf7151291da421987e1272c08044561b9863998c7fcb7a223d334541dfa8f7e242348dc025f55f7ce5c502c7469b0e41b28ab55b4ee8a24fd13d1fcc286c
@@ -0,0 +1,35 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version: ['2.6', '2.7', '3.0']
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - name: Set up Ruby
27
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
+ # uses: ruby/setup-ruby@v1
30
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
31
+ with:
32
+ ruby-version: ${{ matrix.ruby-version }}
33
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34
+ - name: Run tests
35
+ run: bundle exec rake
data/Gemfile.lock CHANGED
@@ -1,34 +1,36 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ssn_validation (0.1.3)
4
+ ssn_validation (0.1.6)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- activemodel (5.2.3)
10
- activesupport (= 5.2.3)
11
- activesupport (5.2.3)
9
+ activemodel (5.2.6)
10
+ activesupport (= 5.2.6)
11
+ activesupport (5.2.6)
12
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
13
  i18n (>= 0.7, < 2)
14
14
  minitest (~> 5.1)
15
15
  tzinfo (~> 1.1)
16
- concurrent-ruby (1.1.5)
17
- i18n (1.7.0)
16
+ concurrent-ruby (1.1.9)
17
+ i18n (1.8.11)
18
18
  concurrent-ruby (~> 1.0)
19
- minitest (5.12.2)
19
+ minitest (5.14.4)
20
20
  rake (12.3.3)
21
21
  thread_safe (0.3.6)
22
- tzinfo (1.2.5)
22
+ tzinfo (1.2.9)
23
23
  thread_safe (~> 0.1)
24
24
 
25
25
  PLATFORMS
26
- ruby
26
+ x86_64-darwin-20
27
+ x86_64-linux
27
28
 
28
29
  DEPENDENCIES
29
30
  activemodel (~> 5)
31
+ minitest
30
32
  rake (~> 12)
31
33
  ssn_validation!
32
34
 
33
35
  BUNDLED WITH
34
- 2.0.2
36
+ 2.2.22
data/Rakefile CHANGED
@@ -1,7 +1,9 @@
1
1
  require 'rake/testtask'
2
2
 
3
3
  Rake::TestTask.new(:test) do |t|
4
- t.pattern = 'test/**/*_test.rb'
4
+ t.libs << "test"
5
+ t.libs << "lib"
6
+ t.test_files = FileList['test/**/*_test.rb']
5
7
  t.verbose = true
6
8
  t.warning = true
7
9
  end
@@ -6,7 +6,7 @@ module SsnValidation
6
6
 
7
7
  # returns a hash of 0..n key/value pairs for ssn validation error codes and a default message for each
8
8
  def self.validate(ssn)
9
- ssn = ssn.to_s
9
+ ssn = ssn.to_s.delete('-') # be lenient with incoming dash chars
10
10
  errors = {}
11
11
  return errors if test_ssn?(ssn)
12
12
 
@@ -50,6 +50,7 @@ module SsnValidation
50
50
  false
51
51
  end
52
52
 
53
+ # https://www.irs.gov/irm/part3/irm_03-021-263r
53
54
  def self.invalid_itin?(ssn)
54
55
  return false unless ssn[0] == "9"
55
56
  group = ssn[3..4].to_i
@@ -7,7 +7,7 @@ module ActiveModel
7
7
  def validate_each(record, attribute, value)
8
8
  ssn_errors = SsnValidation::Ssn.validate(value)
9
9
  return if ssn_errors.blank?
10
- ssn_errors.values.each {|error| record.errors[attribute] << error}
10
+ ssn_errors.values.each { |error| record.errors.add(attribute, error) }
11
11
  end
12
12
  end
13
13
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SsnValidation
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.7'
3
3
  end
@@ -18,5 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.required_ruby_version = '>= 2.3'
19
19
  spec.add_development_dependency "rake", '~> 12'
20
20
  spec.add_development_dependency "activemodel", '~> 5'
21
+ spec.add_development_dependency "minitest"
21
22
  end
22
23
 
@@ -1,5 +1,5 @@
1
1
  require 'minitest/autorun'
2
- require 'ssn_validation/ssn'
2
+ require 'ssn_validation'
3
3
 
4
4
  class SsnTest < Minitest::Test
5
5
  include SsnValidation
@@ -7,66 +7,71 @@ class SsnTest < Minitest::Test
7
7
  describe 'valid formats' do
8
8
  describe 'valid ITIN' do
9
9
  it 'is valid' do
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'))
10
+ _(Ssn.validate('911781111')).must_equal({})
11
+ _(Ssn.validate('911501111')).must_equal({})
12
+ _(Ssn.validate('911651111')).must_equal({})
13
+ _(Ssn.validate('911651111')).must_equal({})
14
+ _(Ssn.validate('911881111')).must_equal({})
15
+ _(Ssn.validate('911901111')).must_equal({})
16
+ _(Ssn.validate('911991111')).must_equal({})
17
17
  end
18
18
  end
19
19
  describe 'valid SSN' do
20
20
  it 'is valid' do
21
- assert_equal({}, Ssn.validate('123432100'))
21
+ _(Ssn.validate('123432100')).must_equal({})
22
22
  end
23
23
  end
24
24
  describe 'valid repeating SSN' do
25
25
  it 'is valid' do
26
- assert_equal({}, Ssn.validate('123444444'))
26
+ _(Ssn.validate('123444444')).must_equal({})
27
+ end
28
+ end
29
+ describe 'valid with dashes' do
30
+ it 'ignores the dashes' do
31
+ _(Ssn.validate('123-44-4444')).must_equal({})
27
32
  end
28
33
  end
29
34
  end
30
35
  describe 'invalid formats' do
31
36
  describe '666 is invalid' do
32
37
  it 'is valid' do
33
- assert_equal({excluded_666: 'SSN value contains excluded area 666-xx-xxxx'}, Ssn.validate('666123210'))
38
+ _(Ssn.validate('666123210')).must_equal({excluded_666: 'SSN value contains excluded area 666-xx-xxxx'})
34
39
  end
35
40
  end
36
41
  describe 'zero area numbers invalid' do
37
42
  it 'is invalid' do
38
- assert_equal({zero_area: 'SSN value contains zeros in area number 000-xx-xxxx'}, Ssn.validate('000567890'))
43
+ _(Ssn.validate('000567890')).must_equal({zero_area: 'SSN value contains zeros in area number 000-xx-xxxx'})
39
44
  end
40
45
  end
41
46
  describe 'zero group numbers invalid' do
42
47
  it 'is invalid' do
43
- assert_equal({zero_group: 'SSN value contains zeros in group number xxx-00-xxxx'}, Ssn.validate('567007890'))
48
+ _(Ssn.validate('567007890')).must_equal({zero_group: 'SSN value contains zeros in group number xxx-00-xxxx'})
44
49
  end
45
50
  end
46
51
  describe 'zero serial numbers invalid' do
47
52
  it 'is invalid' do
48
- assert_equal({zero_serial: 'SSN value contains zeros in serial number xxx-xx-0000'}, Ssn.validate('567890000'))
53
+ _(Ssn.validate('567890000')).must_equal({zero_serial: 'SSN value contains zeros in serial number xxx-xx-0000'})
49
54
  end
50
55
  end
51
56
  describe 'non digits invalid' do
52
57
  it 'is invalid' do
53
- assert_equal({non_digits: 'SSN value contains non-digits'}, Ssn.validate('ABCDEFGHI'))
58
+ _(Ssn.validate('ABCDEFGHI')).must_equal({non_digits: 'SSN value contains non-digits'})
54
59
  end
55
60
  end
56
61
  describe 'not 9 digits invalid' do
57
62
  it 'is invalid' do
58
- assert_equal({nine_digits: 'SSN value is not 9 digits'}, Ssn.validate('303'))
63
+ _(Ssn.validate('303')).must_equal({nine_digits: 'SSN value is not 9 digits'})
59
64
  end
60
65
  end
61
- describe 'repeating digits invalid' do
66
+ describe 'repeating digits invalid' do
62
67
  it 'is invalid' do
63
- assert_equal({repeating: 'SSN value contains repeating digits'}, Ssn.validate('888888888'))
68
+ _(Ssn.validate('888888888')).must_equal({repeating: 'SSN value contains repeating digits'})
64
69
  end
65
70
  end
66
71
  describe 'invalid ITIN' do
67
72
  it 'is invalid' do
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'))
73
+ _(Ssn.validate('900121234')).must_equal({invalid_itin: 'SSN value contains invalid ITIN format 9xx-[x]x-xxxx'})
74
+ _(Ssn.validate('900441234')).must_equal({invalid_itin: 'SSN value contains invalid ITIN format 9xx-[x]x-xxxx'})
70
75
  end
71
76
  end
72
77
  end
@@ -76,46 +81,46 @@ class SsnTest < Minitest::Test
76
81
  end
77
82
  describe 'ascending digits invalid' do
78
83
  it 'is invalid' do
79
- assert_equal({ascending: 'SSN value contains all ASCENDING digits'}, Ssn.validate('123456789'))
80
- assert_equal({ascending: 'SSN value contains all ASCENDING digits'}, Ssn.validate('567891234'))
84
+ _(Ssn.validate('123456789')).must_equal({ascending: 'SSN value contains all ASCENDING digits'})
85
+ _(Ssn.validate('567891234')).must_equal({ascending: 'SSN value contains all ASCENDING digits'})
81
86
  end
82
87
  end
83
88
  describe 'ascending digits ex 0 invalid' do
84
89
  it 'is invalid' do
85
- assert_equal({ascending: 'SSN value contains all ASCENDING digits'}, Ssn.validate('678912345'))
86
- assert_equal({ascending: 'SSN value contains all ASCENDING digits'}, Ssn.validate('123456789'))
87
- assert_equal({ascending: 'SSN value contains all ASCENDING digits'}, Ssn.validate('234567891'))
90
+ _(Ssn.validate('678912345')).must_equal({ascending: 'SSN value contains all ASCENDING digits'})
91
+ _(Ssn.validate('123456789')).must_equal({ascending: 'SSN value contains all ASCENDING digits'})
92
+ _(Ssn.validate('234567891')).must_equal({ascending: 'SSN value contains all ASCENDING digits'})
88
93
  end
89
94
  end
90
95
  describe 'descending digits invalid' do
91
96
  it 'is invalid' do
92
- assert_equal({descending: 'SSN value contains all DESCENDING digits'}, Ssn.validate('876543210'))
93
- assert_equal({descending: 'SSN value contains all DESCENDING digits'}, Ssn.validate('321098765'))
94
- assert_equal({descending: 'SSN value contains all DESCENDING digits'}, Ssn.validate('765432109'))
97
+ _(Ssn.validate('876543210')).must_equal({descending: 'SSN value contains all DESCENDING digits'})
98
+ _(Ssn.validate('321098765')).must_equal({descending: 'SSN value contains all DESCENDING digits'})
99
+ _(Ssn.validate('765432109')).must_equal({descending: 'SSN value contains all DESCENDING digits'})
95
100
  end
96
101
  end
97
102
  describe 'descending digits ex 0 invalid' do
98
103
  it 'is invalid' do
99
- assert_equal({descending: 'SSN value contains all DESCENDING digits'}, Ssn.validate('321987654'))
100
- assert_equal({descending: 'SSN value contains all DESCENDING digits'}, Ssn.validate('765432198'))
104
+ _(Ssn.validate('321987654')).must_equal({descending: 'SSN value contains all DESCENDING digits'})
105
+ _(Ssn.validate('765432198')).must_equal({descending: 'SSN value contains all DESCENDING digits'})
101
106
  end
102
107
  end
103
108
  end
104
109
  describe 'allowing dummy ssns' do
105
110
  it 'allows 666xxxxx' do
106
111
  SsnValidation.config.test_ssns = [/^666/]
107
- assert_equal({}, Ssn.validate('666123456'))
112
+ _(Ssn.validate('666123456')).must_equal({})
108
113
  SsnValidation.config.test_ssns = []
109
114
  end
110
115
  it 'allows random test ssns' do
111
116
  SsnValidation.config.test_ssns = ['509421234']
112
- assert_equal({}, Ssn.validate('509421234'))
117
+ _(Ssn.validate('509421234')).must_equal({})
113
118
  SsnValidation.config.test_ssns = []
114
119
  end
115
120
  it 'allows multiple test ssns' do
116
121
  SsnValidation.config.test_ssns = ['999999999', /^666/]
117
- assert_equal({}, Ssn.validate('666123456'))
118
- assert_equal({}, Ssn.validate('999999999'))
122
+ _(Ssn.validate('666123456')).must_equal({})
123
+ _(Ssn.validate('999999999')).must_equal({})
119
124
  SsnValidation.config.test_ssns = []
120
125
  end
121
126
  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.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Stewart
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-25 00:00:00.000000000 Z
11
+ date: 2021-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -38,12 +38,27 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5'
41
- description:
42
- email:
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
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:
56
+ email:
43
57
  executables: []
44
58
  extensions: []
45
59
  extra_rdoc_files: []
46
60
  files:
61
+ - ".github/workflows/ruby.yml"
47
62
  - Gemfile
48
63
  - Gemfile.lock
49
64
  - README.md
@@ -61,7 +76,7 @@ homepage: https://github.com/johnsinco/ssn_validation
61
76
  licenses:
62
77
  - Apache-2.0
63
78
  metadata: {}
64
- post_install_message:
79
+ post_install_message:
65
80
  rdoc_options: []
66
81
  require_paths:
67
82
  - lib
@@ -76,9 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
91
  - !ruby/object:Gem::Version
77
92
  version: '0'
78
93
  requirements: []
79
- rubyforge_project:
80
- rubygems_version: 2.7.6.2
81
- signing_key:
94
+ rubygems_version: 3.2.22
95
+ signing_key:
82
96
  specification_version: 4
83
97
  summary: Social Security Number (SSN) Validation
84
98
  test_files: