credit_card_validations 6.1.0 → 6.2.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80528d2245ce569ed3b865c186f272d37581606a90ca679e391da8abfd3f003b
|
4
|
+
data.tar.gz: 85100246c15156a33e7c491988edcfddc171f26e63dc38dd4783636becb5912a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 276527c57560abaad1216c80bc76e0e57861337ded7451902e5c872800eaaf7deb00b89d1426adbea3100702ff100179a3a16232728bf541242e3002303c3ffd
|
7
|
+
data.tar.gz: b3ae52f16663e2acf0a6133f170c2f3d73e13aaa1814f7fc4e165d5d93f6282ef4751e8e79f43d174d1ff6f5708c5a3da28aa82180917eecef85df86b09c7111
|
data/.github/workflows/build.yml
CHANGED
data/Changelog.md
CHANGED
@@ -28,8 +28,14 @@ module CreditCardValidations
|
|
28
28
|
def valid_number?(*keys)
|
29
29
|
selected_brands = keys.blank? ? self.brands : resolve_keys(*keys)
|
30
30
|
if selected_brands.any?
|
31
|
+
matched_brands = []
|
31
32
|
selected_brands.each do |key, brand|
|
32
|
-
|
33
|
+
match_data = matches_brand?(brand)
|
34
|
+
matched_brands << {brand: key, matched_prefix_length: match_data.to_s.length} if match_data
|
35
|
+
end
|
36
|
+
|
37
|
+
if matched_brands.present?
|
38
|
+
return matched_brands.sort{|a, b| a[:matched_prefix_length] <=> b[:matched_prefix_length]}.last[:brand]
|
33
39
|
end
|
34
40
|
end
|
35
41
|
nil
|
@@ -64,8 +70,8 @@ module CreditCardValidations
|
|
64
70
|
rules.each do |rule|
|
65
71
|
if (options[:skip_luhn] || valid_luhn?) &&
|
66
72
|
rule[:length].include?(number.length) &&
|
67
|
-
number.match(rule[:regexp])
|
68
|
-
return
|
73
|
+
match_data = number.match(rule[:regexp])
|
74
|
+
return match_data
|
69
75
|
end
|
70
76
|
end
|
71
77
|
false
|
@@ -170,6 +170,28 @@ describe CreditCardValidations do
|
|
170
170
|
end
|
171
171
|
end
|
172
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
|
173
195
|
end
|
174
196
|
|
175
197
|
describe 'plugins' do
|
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.
|
4
|
+
version: 6.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
|
-
rubygems_version: 3.
|
170
|
+
rubygems_version: 3.4.22
|
171
171
|
signing_key:
|
172
172
|
specification_version: 4
|
173
173
|
summary: gem should be used for credit card numbers validation, card brands detections,
|