luhn_validate 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/luhn_validate.rb +4 -2
- 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: 5319bba089008f18c127dfbd48a39e100e82f52e06bcf0610f0ca0357705aea9
|
4
|
+
data.tar.gz: 77211d698a949c0db1456054b0e7fa1bac1f96cee331a0e40dece40491248aca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db8fa3654e14858c0d017483202131b9c7153323a3d476457731342b8db6d7f9ed447d2f19b3081994c081c6599bda6a3f72e352fb3871d87c11d8c78bfdedb5
|
7
|
+
data.tar.gz: 95e6a7e788abae9ce1c8345604516a70d276f2c44d29cee0afb7e17997ecf66c0294185b89ecad8a4193a8c3fa3711288a1a814d583694082ea038ac38722c0a
|
data/lib/luhn_validate.rb
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
class Luhn
|
5
5
|
class CardNotPresentError < StandardError; end
|
6
6
|
class PanLengthError < StandardError; end
|
7
|
+
class PanTypeError < StandardError; end
|
7
8
|
|
8
9
|
attr_reader :pan_array, :card_size, :valid
|
9
10
|
|
@@ -15,9 +16,10 @@ class Luhn
|
|
15
16
|
|
16
17
|
def self.validate(pan)
|
17
18
|
raise CardNotPresentError, 'Card not present' unless pan
|
18
|
-
raise
|
19
|
+
raise PanTypeError, 'Wrong pan type, pan must be either String or Integer' unless pan.is_a?(String) || pan.is_a?(Integer)
|
20
|
+
raise PanLengthError, 'Wrong pan length' unless (14..19).include? pan.to_s.split('').size
|
19
21
|
|
20
|
-
new(pan)
|
22
|
+
new(pan.to_s)
|
21
23
|
end
|
22
24
|
|
23
25
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: luhn_validate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FuryCow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Validate Card PAN by Luhn algorithm
|
14
14
|
email: dreamweaver0408@gmail.com
|