credit_card_validations 6.3.0 → 7.1.0

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: ce0ead55e978be8c471369fbe4153f6976e77af14147f04fe2842a071ec2fde5
4
- data.tar.gz: 2025872d04c07e6eb8a17235aadcfa457ba43596d107b7f9fc01bb627a27d7be
3
+ metadata.gz: 2f4c6436dc5dbb57bfc1f1a84f377d1adac3ee41fd243891d60e3138f31d5b0d
4
+ data.tar.gz: 30523ff8dab806ea03703f4269c7ed769ef026cb660ad862b3603de9915ffa5b
5
5
  SHA512:
6
- metadata.gz: df1051e9d510e163aeeaba35dc1996b4e572cf85618da456748b7f83570625fabc3851db8d1ebc2afe4ca74b1053f3eac0b6877fa8fe67d21707e42e81be0a2b
7
- data.tar.gz: 8d610f9c98752ff404c736af9d30bbc00ee59c538a33c88ea83dde79298df8c2b944c09cf69ed41cdc25c5ea60495f143e9175412bf284e17d738ac3cc77a412
6
+ metadata.gz: 0cd443ca75133dcf28276e4400c908527816aac8bbfaae4313bb2d38209de5664b1323c9c190338d8dea76c614d2df6474a0e3a9586a0186e11fae9b9e035330
7
+ data.tar.gz: 3db166c036247ebda14a488e9c12f996041ddd02452a2e06ea7d170d92dc30afab398738a8af4c57e3131403ca8d47a55d4a5a8f3b04ce46461c07748309f5a8
data/Changelog.md CHANGED
@@ -1,3 +1,14 @@
1
+ # Unreleased
2
+ * Reduce gem size by excluding test files
3
+
4
+ # 7.0.0
5
+ * allow rails 8
6
+ * drop rails 6.1 and rails 7.0
7
+ * drop support of eol ruby versions 2.7, 3.0
8
+
9
+ # 6.3.0
10
+ * rails 7.2 support
11
+
1
12
  # 6.2.0
2
13
  * support ruby 3.3
3
14
  * more accurate brand matching using matched prefix length
@@ -4,14 +4,14 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'credit_card_validations/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
- gem.name = "credit_card_validations"
7
+ gem.name = 'credit_card_validations'
8
8
  gem.version = CreditCardValidations::VERSION
9
- gem.authors = ["Igor"]
10
- gem.email = ["fedoronchuk@gmail.com"]
9
+ gem.authors = ['Igor']
10
+ gem.email = ['fedoronchuk@gmail.com']
11
11
  gem.description = %q{A ruby gem for validating credit card numbers}
12
- gem.summary = "gem should be used for credit card numbers validation, card brands detections, luhn checks"
13
- gem.homepage = "http://didww.github.io/credit_card_validations/"
14
- gem.license = "MIT"
12
+ gem.summary = 'gem should be used for credit card numbers validation, card brands detections, luhn checks'
13
+ gem.homepage = 'http://didww.github.io/credit_card_validations/'
14
+ gem.license = 'MIT'
15
15
 
16
16
  gem.metadata = {
17
17
  'bug_tracker_uri' => 'https://github.com/didww/credit_card_validations/issues',
@@ -19,18 +19,25 @@ Gem::Specification.new do |gem|
19
19
  'source_code_uri' => 'https://github.com/didww/credit_card_validations'
20
20
  }
21
21
 
22
- gem.files = `git ls-files`.split($/)
23
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
22
+ gem.files = Dir.glob('lib/**/*') + [
23
+ 'Changelog.md',
24
+ 'Gemfile',
25
+ 'LICENSE.txt',
26
+ 'Rakefile',
27
+ 'README.md',
28
+ 'credit_card_validations.gemspec',
29
+ ]
30
+
24
31
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
25
- gem.require_paths = ["lib"]
32
+ gem.require_paths = ['lib']
26
33
 
27
34
 
28
- gem.add_dependency "activemodel", ">= 5.2", "< 8.0"
29
- gem.add_dependency "activesupport", ">= 5.2", "< 8.0"
35
+ gem.add_dependency 'activemodel', '>= 5.2', '< 8.2'
36
+ gem.add_dependency 'activesupport', '>= 5.2', '< 8.2'
30
37
 
31
38
 
32
- gem.add_development_dependency "minitest", '~> 5.14.3'
33
- gem.add_development_dependency "mocha", '1.1.0'
39
+ gem.add_development_dependency 'minitest'
40
+ gem.add_development_dependency 'mocha'
34
41
  gem.add_development_dependency 'rake'
35
42
  gem.add_development_dependency 'byebug'
36
43
  end
@@ -1,3 +1,3 @@
1
1
  module CreditCardValidations
2
- VERSION = '6.3.0'
2
+ VERSION = '7.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: credit_card_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.3.0
4
+ version: 7.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-10 00:00:00.000000000 Z
11
+ date: 2026-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '5.2'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '8.0'
22
+ version: '8.2'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '5.2'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '8.0'
32
+ version: '8.2'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activesupport
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '5.2'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '8.0'
42
+ version: '8.2'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,35 +49,35 @@ dependencies:
49
49
  version: '5.2'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '8.0'
52
+ version: '8.2'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: minitest
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - "~>"
57
+ - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 5.14.3
59
+ version: '0'
60
60
  type: :development
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - "~>"
64
+ - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: 5.14.3
66
+ version: '0'
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: mocha
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - '='
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
- version: 1.1.0
73
+ version: '0'
74
74
  type: :development
75
75
  prerelease: false
76
76
  version_requirements: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - '='
78
+ - - ">="
79
79
  - !ruby/object:Gem::Version
80
- version: 1.1.0
80
+ version: '0'
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: rake
83
83
  requirement: !ruby/object:Gem::Requirement
@@ -113,9 +113,6 @@ executables: []
113
113
  extensions: []
114
114
  extra_rdoc_files: []
115
115
  files:
116
- - ".github/workflows/build.yml"
117
- - ".gitignore"
118
- - ".hound.yml"
119
116
  - Changelog.md
120
117
  - Gemfile
121
118
  - LICENSE.txt
@@ -136,15 +133,6 @@ files:
136
133
  - lib/credit_card_validations/string.rb
137
134
  - lib/credit_card_validations/version.rb
138
135
  - lib/data/brands.yaml
139
- - spec/active_model_spec.rb
140
- - spec/credit_card_validations_spec.rb
141
- - spec/factory_spec.rb
142
- - spec/fixtures/invalid_cards.yml
143
- - spec/fixtures/overrided_brands.yml
144
- - spec/fixtures/valid_cards.yml
145
- - spec/models/credit_card.rb
146
- - spec/string_spec.rb
147
- - spec/test_helper.rb
148
136
  homepage: http://didww.github.io/credit_card_validations/
149
137
  licenses:
150
138
  - MIT
@@ -172,13 +160,4 @@ signing_key:
172
160
  specification_version: 4
173
161
  summary: gem should be used for credit card numbers validation, card brands detections,
174
162
  luhn checks
175
- test_files:
176
- - spec/active_model_spec.rb
177
- - spec/credit_card_validations_spec.rb
178
- - spec/factory_spec.rb
179
- - spec/fixtures/invalid_cards.yml
180
- - spec/fixtures/overrided_brands.yml
181
- - spec/fixtures/valid_cards.yml
182
- - spec/models/credit_card.rb
183
- - spec/string_spec.rb
184
- - spec/test_helper.rb
163
+ test_files: []
@@ -1,39 +0,0 @@
1
- name: CI
2
- on:
3
- pull_request:
4
- push:
5
- branches:
6
- - master
7
- jobs:
8
- test:
9
- name: Tests with Ruby ${{ matrix.ruby-version }} Rails ${{ matrix.rails }}
10
- runs-on: ubuntu-latest
11
- strategy:
12
- matrix:
13
- ruby-version:
14
- - 2.7
15
- - '3.0'
16
- - 3.1
17
- - 3.2
18
- - 3.3
19
- rails:
20
- - '6.1.5'
21
- - '7.0.2.3'
22
- - '7.1.0'
23
- - '7.2.0'
24
- exclude:
25
- - ruby-version: 2.7
26
- rails: '7.2.0'
27
- - ruby-version: '3.0'
28
- rails: '7.2.0'
29
- env:
30
- RAILS_VERSION: ${{ matrix.rails }}
31
- steps:
32
- - uses: actions/checkout@v3
33
- - uses: ruby/setup-ruby@v1
34
- with:
35
- ruby-version: ${{ matrix.ruby-version }}
36
- bundler-cache: true
37
- - name: Run tests
38
- run: |
39
- bundle exec rake
data/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- /coverage
2
- /Gemfile.lock
3
- \.ruby-version
data/.hound.yml DELETED
@@ -1,2 +0,0 @@
1
- StringLiterals:
2
- EnforcedStyle: single_quotes
@@ -1,70 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- describe 'ActiveModel Validator' do
4
-
5
- let(:model) { CreditCard.new }
6
-
7
- describe 'Proc support' do
8
- it 'should be valid if brands from proc valid' do
9
- card = model.dup
10
- card.card_type = 'Master Card'
11
- card.number6 = CreditCardValidations::Factory.random(:visa)
12
- expect(card.valid?).must_equal false
13
- card.number6 = CreditCardValidations::Factory.random(:mastercard)
14
- expect(card.valid?).must_equal true
15
- end
16
- end
17
-
18
- describe 'Any Brand' do
19
- it 'should be valid for all prepared valid numbers' do
20
- VALID_NUMBERS.each do |_, numbers|
21
- numbers.each do |number|
22
- card = model
23
- card.number4 = number
24
- card.number5 = number
25
- expect(card.valid?).must_equal true
26
- end
27
- end
28
- end
29
- end
30
-
31
- describe 'Except Amex and Maestro brand' do
32
- it 'should reject all other valid numbers' do
33
- VALID_NUMBERS.except(:amex, :maestro).each do |_, numbers|
34
- card = model
35
- card.number = numbers.first
36
- expect(card.valid?).must_equal false
37
- expect(card.errors[:number].include?(card.errors.generate_message(:number, :invalid))).must_equal true
38
- end
39
- end
40
-
41
- it 'should accept using except options' do
42
- VALID_NUMBERS.except(:amex, :maestro).each do |_, numbers|
43
- card = model
44
- card.number3 = numbers.first
45
- expect(card.valid?).must_equal true
46
- end
47
- end
48
- end
49
-
50
- describe 'Only Amex and Mestro brands' do
51
- it 'should accept amex and maestro brand if valid' do
52
- VALID_NUMBERS.slice(:amex, :maestro).each do |_, numbers|
53
- card = model
54
- card.number = numbers.first
55
- card.number2 = numbers.first
56
- expect(card.valid?).must_equal true
57
- end
58
- end
59
- end
60
-
61
- describe 'Custom error message' do
62
- it 'should allow custom message' do
63
- card = model
64
- card.number7 = 'wrong'
65
- expect(card.valid?).must_equal false
66
- expect(card.errors[:number7]).must_equal ['Custom message']
67
- end
68
- end
69
-
70
- end
@@ -1,230 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- describe CreditCardValidations do
4
-
5
-
6
- before do
7
- CreditCardValidations.reload!
8
- end
9
-
10
-
11
- describe 'configure' do
12
-
13
- let(:number) { '6111111180456137' }
14
-
15
- before do
16
- expect(card_detector.valid?(:discover)).must_equal false
17
- CreditCardValidations.configure do |config|
18
- config.source = OVERRIDED_BRANDS_FILE
19
- end
20
- end
21
-
22
- let(:card_detector) {
23
- detector(number)
24
- }
25
-
26
- it 'should generate overrided discover' do
27
- discover = CreditCardValidations::Factory.random(:discover)
28
- expect(detector(discover).valid?('DiscoverBrand')).must_equal true
29
- end
30
-
31
- it 'should detect patched discover' do
32
- expect(card_detector.valid?(:discover)).must_equal true
33
- expect(card_detector.valid?(:visa)).must_equal false
34
- end
35
-
36
- after do
37
- CreditCardValidations.reset
38
- CreditCardValidations.reload!
39
- end
40
-
41
- end
42
-
43
- describe 'MMI' do
44
- it 'should detect issuer category' do
45
- d = detector(VALID_NUMBERS[:visa].first)
46
- expect(d.issuer_category).must_equal CreditCardValidations::Mmi::ISSUER_CATEGORIES[d.number[0]]
47
- end
48
- end
49
-
50
- describe 'Luhn#valid?' do
51
- let(:card_detector) {
52
- detector(VALID_NUMBERS[:unionpay].first)
53
- }
54
- it 'should call Luhn.valid? once' do
55
- CreditCardValidations::Luhn.expects(:valid?).with(card_detector.number).once
56
- expect(card_detector.valid?(:visa, :unionpay)).must_equal true
57
- end
58
-
59
- it 'should call Luhn.valid? twice' do
60
- CreditCardValidations::Luhn.expects(:valid?).with(card_detector.number).twice
61
- expect(card_detector.valid?(:visa, :mastercard)).must_equal false
62
- end
63
-
64
- it 'should not call Luhn.valid?' do
65
- CreditCardValidations::Luhn.expects(:valid?).never
66
- expect(card_detector.valid?(:unionpay)).must_equal true
67
- end
68
-
69
- end
70
-
71
-
72
- it 'should check luhn' do
73
- VALID_NUMBERS.each do |brand, card_numbers|
74
- if has_luhn_check_rule?(brand)
75
- card_numbers.each do |number|
76
- expect(luhn_valid?(detector(number).number)).must_equal true
77
- end
78
- end
79
- end
80
- end
81
-
82
- it 'should check valid brand' do
83
- VALID_NUMBERS.each do |brand, card_numbers|
84
- card_numbers.each do |card_number|
85
- expect(detector(card_number).send("#{brand}?")).must_equal true
86
- expect(detector(card_number).brand).must_equal brand
87
- end
88
- end
89
- end
90
-
91
- it 'should check if card invalid' do
92
- INVALID_NUMBERS.each do |card_number|
93
- expect(detector(card_number).valid?).must_equal false
94
- expect(detector(card_number).brand).must_be_nil
95
- VALID_NUMBERS.keys.each do |brand|
96
- expect(detector(card_number).send("#{brand}?")).must_equal false
97
- end
98
- end
99
- end
100
-
101
- it 'should detect by full brand name' do
102
- amex = CreditCardValidations::Factory.random(:amex)
103
- expect(detector(amex).valid?('American Express')).must_equal true
104
- visa = CreditCardValidations::Factory.random(:visa)
105
- expect(detector(visa).valid?('American Express')).must_equal false
106
- end
107
-
108
- it 'should support multiple brands for single check' do
109
- VALID_NUMBERS.slice(:visa, :mastercard).each do |key, value|
110
- expect(detector(value.first).brand(:visa, :mastercard)).must_equal key
111
- end
112
-
113
- VALID_NUMBERS.except(:visa, :mastercard).each do |_, value|
114
- expect(detector(value.first).brand(:visa, :mastercard)).must_be_nil
115
- end
116
- end
117
-
118
- it 'should check if valid brand without arguments' do
119
- VALID_NUMBERS.each do |key, value|
120
- value.each do |card_number|
121
- expect(detector(card_number).valid?(key)).must_equal true
122
- expect(assert detector(card_number).valid?).must_equal true
123
- end
124
- end
125
- end
126
-
127
- it 'should not be valid? if wrong brand' do
128
- expect(detector(VALID_NUMBERS[:visa].first).valid?(:mastercard)).must_equal false
129
- expect(detector(VALID_NUMBERS[:mastercard].first).valid?(:visa)).must_equal false
130
- end
131
-
132
- it 'should be valid? if right brand' do
133
- expect(detector(VALID_NUMBERS[:visa].first).valid?(:mastercard, :visa)).must_equal true
134
- expect(detector(VALID_NUMBERS[:visa].first).valid?(:mastercard, :amex)).must_equal false
135
- end
136
-
137
-
138
- describe 'adding/removing brand' do
139
-
140
- describe 'adding rules' do
141
-
142
- let(:voyager_number) { '869926275400212' }
143
-
144
- it 'should validate number as voyager' do
145
- CreditCardValidations::Detector.add_brand(:voyager, length: 15, prefixes: '86')
146
- expect(detector(voyager_number).valid?(:voyager)).must_equal true
147
- expect(detector(voyager_number).voyager?).must_equal true
148
- expect(detector(voyager_number).brand).must_equal :voyager
149
- end
150
-
151
- describe 'Add voyager rule' do
152
- before do
153
- CreditCardValidations::Detector.add_brand(:voyager, length: 15, prefixes: '86')
154
- end
155
-
156
- it 'should validate number as voyager' do
157
- expect(detector(voyager_number).valid?(:voyager)).must_equal true
158
- expect(detector(voyager_number).voyager?).must_equal true
159
- expect(detector(voyager_number).brand).must_equal :voyager
160
- end
161
-
162
- describe 'Remove voyager rule' do
163
- before do
164
- CreditCardValidations::Detector.delete_brand(:voyager)
165
- end
166
-
167
- it 'should not validate number as voyager' do
168
- expect(detector(voyager_number).respond_to?(:voyager?)).must_equal false
169
- expect(detector(voyager_number).brand).must_be_nil
170
- end
171
- end
172
- end
173
-
174
- describe 'Add kortimilli rule' do
175
- let(:kortimilli_number) { '505827028341713' }
176
-
177
- it 'before invoke add_brand credit card behaves like maestro' do
178
- expect(detector(kortimilli_number).valid?(:maestro)).must_equal true
179
- expect(detector(kortimilli_number).maestro?).must_equal true
180
- expect(detector(kortimilli_number).brand).must_equal :maestro
181
- end
182
-
183
- describe 'after adding wider prefix for kortimilli' do
184
- before do
185
- CreditCardValidations::Detector.add_brand(:kortimilli, length: 15, prefixes: '505827028')
186
- end
187
-
188
- it 'should validate number as kortimilli' do
189
- expect(detector(kortimilli_number).valid?(:kortimilli)).must_equal true
190
- expect(detector(kortimilli_number).kortimilli?).must_equal true
191
- expect(detector(kortimilli_number).brand).must_equal :kortimilli
192
- end
193
- end
194
- end
195
- end
196
-
197
- describe 'plugins' do
198
- [:diners_us, :en_route, :laser].each do |brand|
199
- it "should support #{brand}" do
200
- expect(-> { CreditCardValidations::Factory.random(brand) }).
201
- must_raise(CreditCardValidations::Error)
202
- custom_number = 'some_number'
203
- expect(detector(custom_number).respond_to?("#{brand}?")).must_equal false
204
- require "credit_card_validations/plugins/#{brand}"
205
- number = CreditCardValidations::Factory.random(brand)
206
- expect(detector(number).valid?("#{brand}".to_sym)).must_equal true
207
- expect(detector(custom_number).respond_to?("#{brand}?")).must_equal true
208
- end
209
- end
210
- end
211
-
212
- it 'should raise Error if no brand added before' do
213
- expect(-> { CreditCardValidations::Detector::add_rule(:undefined_brand, 20, [20]) }).
214
- must_raise(CreditCardValidations::Error)
215
- end
216
- end
217
-
218
- def luhn_valid?(number)
219
- CreditCardValidations::Luhn.valid?(number)
220
- end
221
-
222
- def detector(number)
223
- CreditCardValidations::Detector.new(number)
224
- end
225
-
226
- def has_luhn_check_rule?(key)
227
- CreditCardValidations::Detector.has_luhn_check_rule?(key)
228
- end
229
-
230
- end
data/spec/factory_spec.rb DELETED
@@ -1,18 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- describe CreditCardValidations::Factory do
4
-
5
- it 'should generate random brand' do
6
- number = CreditCardValidations::Factory.random
7
- expect(CreditCardValidations::Detector.new(number).valid?).must_equal true
8
- end
9
-
10
- CreditCardValidations::Detector.brands.keys.sort.each do |key|
11
- describe "#{key}" do
12
- it "should generate valid #{key}" do
13
- number = CreditCardValidations::Factory.random(key)
14
- expect(CreditCardValidations::Detector.new(number).valid?(key)).must_equal true
15
- end
16
- end
17
- end
18
- end
@@ -1,6 +0,0 @@
1
- ---
2
- - '1111111111111111'
3
- - '00000000000000'
4
- - fakenumber
5
- - c4111111111111111
6
- - 4111111111111111i
@@ -1,19 +0,0 @@
1
- ---
2
- :visa:
3
- :rules:
4
- - :length:
5
- - 13
6
- - 16
7
- - 19
8
- :prefixes:
9
- - '4'
10
- :options:
11
- :brand_name: Visa
12
- :discover:
13
- :rules:
14
- - :length:
15
- - 16
16
- :prefixes:
17
- - '61111111'
18
- :options:
19
- :brand_name: DiscoverBrand
@@ -1,201 +0,0 @@
1
- ---
2
- :visa:
3
- - 4012 8888 8888 1881
4
- - 4111 1111 1111 1111
5
- - 4222 2222 2222 2
6
- - 4917 6100 0000 0000
7
- :mastercard:
8
- - 5274 5763 9425 9961
9
- - 5555 5555 5555 4444
10
- - 5105 1051 0510 5100
11
- - 2720 1700 0000 0006
12
- - 2223 4800 0000 0001
13
- - 2223 0400 0000 0003
14
- - 2223 0700 0000 0000
15
- - 2223 2700 0000 0006
16
- - 2720 3500 0000 0004
17
- - 2223 1000 0000 0005
18
- - 2720 0500 0000 0000
19
- :diners:
20
- - 3020 4169 3226 43
21
- - 3021 8047 1965 57
22
- - 3022 1511 5632 52
23
- - 3600 0000 0000 08
24
- - 3614 8900 6479 13
25
- - 3670 0102 0000 00
26
- - 3852 0000 0232 37
27
- - 3056 9309 0259 04
28
- - 3020 4169 3226 43
29
- :amex:
30
- - 3714 4963 5398 431
31
- - 3787 3449 3671 000
32
- - 3400 0000 0000 009
33
- - 3411 1111 1111 111
34
- - 3434 3434 3434 343
35
- - 3468 2763 0435 344
36
- - 3700 0000 0000 002
37
- - 3700 0020 0000 000
38
- - 3704 0726 9909 809
39
- - 3705 5601 9309 221
40
- - 3714 4963 5398 431
41
- - 3742 0000 0000 004
42
- - 3764 6228 0921 451
43
- - 3777 5274 9896 404
44
- - 3782 8224 6310 005
45
- :discover:
46
- - 6011 0009 9013 9424
47
- - 6011 0000 0000 0004
48
- - 6011 0004 0000 0000
49
- :maestro:
50
- - 6759 6498 2643 8453
51
- - 5641 8200 0000 0005
52
- - 5033 9619 8909 17
53
- - 5868 2416 0825 5333 38
54
- - 6167 8856 4660 5238
55
- - 6218 3782 7162 0705
56
- - 6218 6064 1843 1366
57
- - 6218 8455 3580 6171
58
- - 6219 8470 1538 3118
59
- - 6219 9203 6534 5837
60
- - 6220 1885 7707 6726
61
- - 6221 1083 1803 2381
62
- - 6270 8984 1174 5752
63
- - 6270 9601 6484 7142
64
- - 6271 0126 3275 2014
65
- - 6272 5470 0241 5113
66
- - 6273 5523 8170 6073
67
- - 6274 4145 1171 2555
68
- - 6275 3486 8618 0058
69
- - 6276 0982 4454 3458
70
- - 6277 6702 4773 1576
71
- - 6278 1636 1660 6511
72
- - 6279 7366 4387 5768
73
- - 6280 4737 1307 4604
74
- - 6281 5524 1682 8637
75
- - 6294 4318 2601 2816
76
- - 6301 1412 8720 7778
77
- - 6304 9003 0332 3654
78
- - 6304 9086 6523 0248 21
79
- - 6338 5705 2835 6175
80
- - 6360 9440 0747 0123
81
- - 6361 4178 1150 8502
82
- - 6363 9214 5556 2632
83
- - 6367 0803 6033 4748
84
- - 6370 4379 0022 2632
85
- - 6371 0283 5125 2860
86
- - 6371 1802 0780 5415
87
- - 6371 8718 1864 7655
88
- - 6375 2978 8623 4844
89
- - 6400 0578 8840 6561
90
- - 6799 9901 0000 0000 019
91
- - 6390 0200 0000 000003
92
- - 6304 9000 1774 0292 441
93
- :jcb:
94
- - 3575 7591 5225 4876
95
- - 3566 0020 2036 0505
96
- - 1800 0163 8277 392
97
- - 3569 9900 0000 0009
98
- - 3530 1113 3330 0000
99
- - 3572 6600 0000 0000 006
100
- :solo:
101
- - 6767 6222 2222 2222 222
102
- - 6334 5805 0000 0000
103
- - 6334 9000 0000 0005
104
- - 6334 7306 0000 0000 00
105
- - 6767 6767 6767 6767 671
106
- :unionpay:
107
- - 6205 4687 6758 6422
108
- - 6210 0345 5222 3424
109
- - 6212 2545 6614 8478
110
- - 6213 0005 0723 4136
111
- - 6214 0114 0514 5414
112
- - 6215 4794 3842 9213
113
- - 6216 2080 3647 3680
114
- - 6217 3228 8155 9136
115
- - 6219 7704 6772 7014
116
- - 6221 2610 6056 0875
117
- - 6221 2703 3387 7511
118
- - 6221 2860 4501 8723
119
- - 6221 2940 0187 5508
120
- - 6221 3008 0432 3735
121
- - 6221 4035 2650 5041
122
- - 6221 5050 3211 0387
123
- - 6221 6206 2057 6335
124
- - 6221 7084 6822 1773
125
- - 6221 8075 5266 5356
126
- - 6222 0036 3722 7888
127
- - 6222 1058 8000 7162
128
- - 6222 2061 3672 5803
129
- - 6222 3068 2276 5616
130
- - 6222 4053 4600 2835
131
- - 6222 5203 3381 7225
132
- - 6222 6080 1686 1014
133
- - 6222 7088 5121 8153
134
- - 6222 8035 1083 2211
135
- - 6222 9175 6828 0444
136
- - 6223 7906 8294 4834
137
- - 6224 0617 0122 1813
138
- - 6225 2033 2312 4467
139
- - 6226 0315 6271 3412
140
- - 6227 5171 6866 2101
141
- - 6228 3658 3631 6034
142
- - 6229 9701 3846 6087
143
- - 6230 0388 8477 1162
144
- - 6234 6051 1836 1717
145
- - 6244 1608 1703 3165
146
- - 6251 7173 7983 2118
147
- - 6262 1704 1722 3287
148
- - 6264 1852 1292 2132 067
149
- - 6269 9920 5813 4322
150
- - 6270 2754 6260 5740
151
- - 6270 4000 5254 5060
152
- - 6270 6014 6481 7266
153
- - 6270 7647 4746 0500
154
- - 6282 7754 7900 5608
155
- - 6283 5632 6428 3062
156
- - 6284 6110 6682 6452
157
- - 6291 8025 7481 1158
158
- - 6292 6014 3461 6826
159
- - 6320 6205 2613 4288
160
- - 6858 0012 5116 6441
161
- - 6907 5577 4227 8443
162
- :dankort:
163
- - 5019 7170 1010 3742
164
- :switch:
165
- - 6331 1019 9999 0016
166
- :rupay:
167
- - 6076 6000 0619 9992
168
- - 6070 5500 5000 0047
169
- :hipercard:
170
- - 3841 0058 9908 8180 330
171
- :elo:
172
- - '4011 7841 3850 9070'
173
- - '4389 3555 4728 7502'
174
- - '4573 9320 5642 0699'
175
- - '4576 3198 7564 9522'
176
- - '5041 7572 2687 1008'
177
- - '5066 9917 1703 9876'
178
- - '5067 5391 6526 0388'
179
- - '5090 4071 4078 7707'
180
- - '5090 4270 1119 7080'
181
- - '5090 4344 4788 5021'
182
- - '5090 4514 6675 8555'
183
- - '5090 4673 1437 9707'
184
- - '5090 4791 2220 0924'
185
- - '5090 4854 1570 5059'
186
- - '5090 4968 1280 8652'
187
- - '5090 5097 0678 9193'
188
- - '5090 5157 9762 1083'
189
- - '5090 5225 6947 6964'
190
- - '5090 6473 8030 4070'
191
- - '5090 6644 0324 2820'
192
- - '5090 6724 8089 9317'
193
- - '5090 6888 2173 4488'
194
- - '5090 6948 3784 4758'
195
- - '5090 7463 8779 6948'
196
- - '6362 9745 2190 7765'
197
- - '6363 6850 2897 2643'
198
- - '6504 9799 9991 0279'
199
- - '6516 5299 9991 0328'
200
- :mir:
201
- - 2202 1234 1234 1234
@@ -1,19 +0,0 @@
1
- class CreditCard
2
- attr_accessor :number, :number2, :number3, :number4, :number5, :number6, :number7, :card_type
3
- include ActiveModel::Validations
4
- validates :number, credit_card_number: { brands: [:amex, :maestro] }, allow_blank: true
5
- validates :number2, credit_card_number: { only: [:amex, :maestro] }, allow_blank: true
6
- validates :number3, credit_card_number: { except: [:amex, :maestro] }, allow_blank: true
7
- validates :number4, credit_card_number: { brands: :any }, allow_blank: true
8
- validates :number5, credit_card_number: true, allow_blank: true
9
- validates :number6, credit_card_number: { brands: ->(record) { record.supported_brand } }, allow_blank: true
10
- validates :number7, credit_card_number: { message: 'Custom message' }, allow_blank: true
11
-
12
- def supported_brand
13
- {
14
- 'Master Card' => :mastercard,
15
- 'Visa' => :visa
16
- }[self.card_type]
17
- end
18
-
19
- end
data/spec/string_spec.rb DELETED
@@ -1,32 +0,0 @@
1
- require_relative 'test_helper'
2
- require 'credit_card_validations/string'
3
-
4
- describe 'String ext' do
5
-
6
- let(:mastercard) { CreditCardValidations::Factory.random(:mastercard) }
7
- let(:visa) { CreditCardValidations::Factory.random(:visa) }
8
- let(:invalid) { INVALID_NUMBERS.sample }
9
-
10
- it 'should allow detect brand for mastercard' do
11
- expect(mastercard.credit_card_brand).must_equal :mastercard
12
- expect(mastercard.credit_card_brand_name).must_equal 'MasterCard'
13
- expect(mastercard.valid_credit_card_brand?(:mastercard)).must_equal true
14
- expect(mastercard.valid_credit_card_brand?('MasterCard')).must_equal true
15
- expect(mastercard.valid_credit_card_brand?(:visa, :amex)).must_equal false
16
- end
17
-
18
- it 'should allow detect brand for visa' do
19
- expect(visa.credit_card_brand).must_equal :visa
20
- expect(visa.credit_card_brand_name).must_equal 'Visa'
21
- expect(visa.valid_credit_card_brand?(:mastercard)).must_equal false
22
- expect(visa.valid_credit_card_brand?(:visa, :amex)).must_equal true
23
- end
24
-
25
- it 'should not allow detect brand for invalid card' do
26
- expect(invalid.credit_card_brand).must_be_nil
27
- expect(invalid.credit_card_brand_name).must_be_nil
28
- expect(invalid.valid_credit_card_brand?(:mastercard)).must_equal false
29
- expect(invalid.valid_credit_card_brand?(:visa, :amex)).must_equal false
30
- end
31
-
32
- end
data/spec/test_helper.rb DELETED
@@ -1,19 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'i18n'
3
- require 'mocha/mini_test'
4
- require 'byebug'
5
-
6
- lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
7
- specs = File.expand_path("#{File.dirname(__FILE__)}/../spec")
8
- $:.unshift(lib)
9
- $:.unshift(specs)
10
-
11
- I18n.config.enforce_available_locales = true
12
-
13
- require 'credit_card_validations'
14
- require 'models/credit_card'
15
-
16
- VALID_NUMBERS = YAML.load_file File.join(File.dirname(__FILE__), 'fixtures/valid_cards.yml')
17
- INVALID_NUMBERS = YAML.load_file File.join(File.dirname(__FILE__), 'fixtures/invalid_cards.yml')
18
- OVERRIDED_BRANDS_FILE = File.join(File.dirname(__FILE__), 'fixtures/overrided_brands.yml')
19
-