debitcard_validator 0.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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +32 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/debitcard_validator.gemspec +26 -0
- data/lib/active_model/validations/debitcard_validator.rb +49 -0
- data/lib/debitcard_validator/version.rb +3 -0
- data/lib/debitcard_validator.rb +5 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 082b5e3c4198d07beea5f9650e1fd9744b0a6505
|
4
|
+
data.tar.gz: d10babb549161582e91acfb13de15258c815a409
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fcfe0c898eb20fa9ca43994d6c2bd70af2147958ebf37961103651ce275448b96138fbd51caaf4809242006a26e6d2b86db7de5e9493ebad4d80016896ec5d46
|
7
|
+
data.tar.gz: 381f27afad07659e2302804582d92f893a669c7d60e9ad7713b12122dbd8325485e26f3f57066c185be42cb41713c7ebc02aa2982a1f12d7441c1b01e8ffde6c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# DebitcardValidator
|
2
|
+
[](https://travis-ci.org/kurotaky/debitcard_validator)
|
3
|
+
[](https://codeclimate.com/github/kurotaky/debitcard_validator)
|
4
|
+
|
5
|
+
debitcard_validator validates Debitcard/Prepaidcard based on Issuer Identifier Number(follows ISO/IEC 7812).
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'debitcard_validator'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
```
|
17
|
+
bundle install
|
18
|
+
```
|
19
|
+
|
20
|
+
Then add the following to your model:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
validates :number, debitcard: true
|
24
|
+
```
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it ( https://github.com/kurotaky/debitcard_validator/fork )
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "debitcard_validator"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'debitcard_validator/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "debitcard_validator"
|
8
|
+
spec.version = DebitcardValidator::VERSION
|
9
|
+
spec.authors = ["Yuta Kurotaki"]
|
10
|
+
spec.email = ["yuta.kurotaki@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{a debitcard validator for Rails Apprication.}
|
13
|
+
spec.description = %q{debitcard_validator validates Debitcard/Prepaidcard based on Issuer Identifier Number(follows ISO/IEC 7812).}
|
14
|
+
spec.homepage = "https://github.com/kurotaky/debitcard_validator"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "activemodel"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'active_model/validations'
|
2
|
+
|
3
|
+
module ActiveModel
|
4
|
+
module Validations
|
5
|
+
class DebitcardValidator < ActiveModel::EachValidator
|
6
|
+
def validate_each(record, attribute, value)
|
7
|
+
value = trim_number(value)
|
8
|
+
if value =~ debitcard_regexes
|
9
|
+
record.errors.add(attribute, 'is debitcard.')
|
10
|
+
end
|
11
|
+
|
12
|
+
if value =~ prepaidcard_regexes
|
13
|
+
record.errors.add(attribute, 'is prepaidcard.')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
# Debitcards
|
20
|
+
#
|
21
|
+
# Nikko Platinum: 415314
|
22
|
+
# SURUGA Bank: 421614,421615,421641
|
23
|
+
# e Bank Money CLASSIC: 454202
|
24
|
+
# e Bank Money GOLD: 454203
|
25
|
+
# Resona Visa Debit: 454205
|
26
|
+
# CALIFORNIA BANK & TRUST: 473063
|
27
|
+
# UNION BANK OF CALIFORNIA: 540997
|
28
|
+
#
|
29
|
+
def debitcard_regexes
|
30
|
+
/(^415314|^421614|^421615|^421641|^454202|^454203|^454205|^473063|^540997)/
|
31
|
+
end
|
32
|
+
|
33
|
+
# Prepaidcards
|
34
|
+
#
|
35
|
+
# V Preca: 428485
|
36
|
+
# NEO MONEY: 428487
|
37
|
+
# Cocokara Club Card: 428490
|
38
|
+
# AMEX GIFT Card: 379029
|
39
|
+
#
|
40
|
+
def prepaidcard_regexes
|
41
|
+
/(^428485|^428487|^428490|^379029)/
|
42
|
+
end
|
43
|
+
|
44
|
+
def trim_number(value)
|
45
|
+
value.to_s.gsub('-', '').gsub(' ', '') unless value.nil?
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: debitcard_validator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yuta Kurotaki
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activemodel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.9'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: debitcard_validator validates Debitcard/Prepaidcard based on Issuer Identifier
|
70
|
+
Number(follows ISO/IEC 7812).
|
71
|
+
email:
|
72
|
+
- yuta.kurotaki@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
80
|
+
- Gemfile
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- debitcard_validator.gemspec
|
86
|
+
- lib/active_model/validations/debitcard_validator.rb
|
87
|
+
- lib/debitcard_validator.rb
|
88
|
+
- lib/debitcard_validator/version.rb
|
89
|
+
homepage: https://github.com/kurotaky/debitcard_validator
|
90
|
+
licenses: []
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.4.5
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: a debitcard validator for Rails Apprication.
|
112
|
+
test_files: []
|