bicvalidator 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Appraisals +15 -0
- data/bicvalidator.gemspec +1 -1
- data/gemfiles/rails_3.0.gemfile +8 -0
- data/gemfiles/rails_4.0.gemfile +8 -0
- data/gemfiles/rails_4.2.gemfile +8 -0
- data/gemfiles/rails_5.0.gemfile +8 -0
- data/lib/bicvalidator.rb +9 -2
- data/lib/bicvalidator/bic.rb +97 -0
- data/lib/bicvalidator/bic_model_validator.rb +11 -0
- data/lib/bicvalidator/version.rb +1 -1
- data/lib/locales/de.yml +8 -0
- data/lib/locales/en.yml +8 -0
- metadata +11 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cf499d2b2c72ca034d2eea94f5b1c85434eff03
|
4
|
+
data.tar.gz: 80586fc2866526f40ca682cf4863f0f75722788a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb7cf46367c94f7b5935c69a6c4d60572da2252f526572e2fc354eb01763fd99e0082e9866a55178162f3452c84e7658f94808bee7d9c2358c7c935f5a3ad32b
|
7
|
+
data.tar.gz: e254564ebc560dc09fff8f1b2ceda9841782c286696c1455d37b57b26bb3113755c2c55df3654818f4230e6cbda138719da214a9c71419c1b05edda4bc79ceda
|
data/.gitignore
CHANGED
data/Appraisals
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
appraise 'rails 3.0' do
|
2
|
+
gem 'activesupport', '~>3.0.0'
|
3
|
+
end
|
4
|
+
|
5
|
+
appraise 'rails 4.0' do
|
6
|
+
gem 'activesupport', '~>4.0.0'
|
7
|
+
end
|
8
|
+
|
9
|
+
appraise 'rails 4.2' do
|
10
|
+
gem 'activesupport', '~>4.2.0'
|
11
|
+
end
|
12
|
+
|
13
|
+
appraise 'rails 5.0' do
|
14
|
+
gem 'activesupport', '~>5.0.0'
|
15
|
+
end
|
data/bicvalidator.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
end
|
29
29
|
spec.bindir = "exe"
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
-
spec.require_paths = ["lib"]
|
31
|
+
spec.require_paths = ["lib","lib/bicvalidator"]
|
32
32
|
|
33
33
|
spec.add_development_dependency "bundler", "~> 1.15"
|
34
34
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/bicvalidator.rb
CHANGED
@@ -2,10 +2,13 @@ require "bicvalidator/version"
|
|
2
2
|
require 'active_model'
|
3
3
|
require 'active_support'
|
4
4
|
require 'active_support/core_ext'
|
5
|
-
require "bicvalidator/bic"
|
6
|
-
require 'bicvalidator/bic_model_validator'
|
7
5
|
#brauch ich fuer laendercodes ISO3166::Country
|
8
6
|
require 'countries'
|
7
|
+
|
8
|
+
require "bicvalidator/bic"
|
9
|
+
require 'bicvalidator/bic_model_validator'
|
10
|
+
|
11
|
+
|
9
12
|
module Bicvalidator
|
10
13
|
mattr_accessor :sepa_bic_countries
|
11
14
|
mattr_accessor :countries
|
@@ -14,7 +17,11 @@ module Bicvalidator
|
|
14
17
|
Bicvalidator.sepa_bic_countries = ["AT", "BE", "BG", "CH", "CY", "CZ", "DE", "DK", "EE", "ES", "FI", "FR", "GB", "GR", "HR", "HU", "IE", "IT", "LI", "LT", "LU", "LV", "MC", "MT", "NL", "NO", "PL", "PT", "RO", "SE", "SI", "SK", "SM", "GI", "GF", "GP", "GG", "IS", "IM", "JE", "MQ", "YT", "RE", "BL", "MF", "PM"]
|
15
18
|
Bicvalidator.countries = ISO3166::Country.translations.keys
|
16
19
|
Bicvalidator.eu_countries = ISO3166::Country.all.select {|it| it.in_eu?}.map{|et| et.alpha2}
|
20
|
+
|
21
|
+
|
17
22
|
end
|
23
|
+
|
18
24
|
ActiveModel::Validations.send(:include, Bicvalidator)
|
25
|
+
|
19
26
|
I18n.load_path += Dir[File.expand_path(File.join(File.dirname(__FILE__),
|
20
27
|
'/locales', '*.yml')).to_s]
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Bicvalidator
|
2
|
+
class Bic
|
3
|
+
attr_accessor :bic_code, :bank, :country, :location, :branch
|
4
|
+
def initialize(bic_str)
|
5
|
+
##strip reicht nicht denn strip entfernt nur leerzeichen vorne und hinten
|
6
|
+
@bic_code = bic_str.strip.gsub(/\s+/, '').upcase
|
7
|
+
end
|
8
|
+
def errorcode
|
9
|
+
return if valid?
|
10
|
+
return "BV0010" if !has_valid_lenght?
|
11
|
+
return "BV0011" if !has_valid_format?
|
12
|
+
return "BV0012" if !valid_country_code?
|
13
|
+
return "BV0013" if !valid_location_code?
|
14
|
+
return "BV0014" if !valid_branch_code?
|
15
|
+
end
|
16
|
+
#in instanz
|
17
|
+
def valid?
|
18
|
+
has_valid_lenght? && has_valid_format? && valid_country_code? && valid_location_code? && valid_branch_code?
|
19
|
+
end
|
20
|
+
|
21
|
+
def has_valid_lenght?
|
22
|
+
[8, 11].include? @bic_code.length
|
23
|
+
end
|
24
|
+
|
25
|
+
def has_valid_format?
|
26
|
+
!(@bic_code =~ bic_iso_format).nil?
|
27
|
+
end
|
28
|
+
|
29
|
+
def valid_country_code?
|
30
|
+
Bicvalidator.countries.include? country
|
31
|
+
end
|
32
|
+
|
33
|
+
def valid_location_code?
|
34
|
+
#http://de.wikipedia.org/wiki/ISO_9362
|
35
|
+
#2-stellige Codierung des Ortes in zwei Zeichen. Das erste Zeichen darf nicht die Ziffer „0“ oder „1“ sein.
|
36
|
+
#Der Buchstabe 'O' ist als zweites Zeichen nicht gestattet.
|
37
|
+
!(location[0] =~ /[^01]/ && location[1] =~ /[^O]/).nil?
|
38
|
+
end
|
39
|
+
|
40
|
+
def valid_branch_code?
|
41
|
+
#Der Branch-Code darf nicht mit „X“ anfangen, es sei denn, es ist „XXX“.
|
42
|
+
return true if @bic_code.length == 8
|
43
|
+
return true if branch == "XXX"
|
44
|
+
(branch[0] =~ /[X]/).nil?
|
45
|
+
end
|
46
|
+
|
47
|
+
def eu?
|
48
|
+
@eu ||= (valid? and Bicvalidator.eu_countries.include? country)
|
49
|
+
end
|
50
|
+
|
51
|
+
def non_eu?
|
52
|
+
@non_eu ||= (valid? and !eu?)
|
53
|
+
end
|
54
|
+
|
55
|
+
def sepa_scheme?
|
56
|
+
#es koennen auch laender am SEAP teilnhmen die nicht in de rEU sind, wie zb CH
|
57
|
+
valid? and Bicvalidator.sepa_bic_countries.include? country
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
def bank
|
62
|
+
@bank ||= match[1]
|
63
|
+
end
|
64
|
+
|
65
|
+
def country
|
66
|
+
@country ||= match[2]
|
67
|
+
end
|
68
|
+
|
69
|
+
def location
|
70
|
+
@location ||= match[3]
|
71
|
+
end
|
72
|
+
|
73
|
+
def branch
|
74
|
+
@branch ||= match[4]
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def bic_iso_format
|
80
|
+
#https://de.wikipedia.org/wiki/ISO_9362
|
81
|
+
#BBBB 4-stelliger Bankcode, vom Geldinstitut frei wählbar
|
82
|
+
#CC 2-stelliger Ländercode nach ISO 3166-1
|
83
|
+
#LL 2-stellige Codierung des Ortes in zwei Zeichen.
|
84
|
+
#Das erste Zeichen darf nicht die Ziffer „0“ oder „1“ sein.
|
85
|
+
#Wenn das zweite Zeichen kein Buchstabe, sondern eine Ziffer ist, so bedeutet dies:
|
86
|
+
#bbb 3-stellige Kennzeichnung (Branch-Code) der Filiale oder Abteilung (optional)
|
87
|
+
#test in http://rubular.com/
|
88
|
+
/([A-Z]{4})([A-Z]{2})([0-9A-Z]{2})([0-9A-Z]{3})?/
|
89
|
+
end
|
90
|
+
|
91
|
+
def match
|
92
|
+
bic_iso_format.match(@bic_code)
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
data/lib/bicvalidator/version.rb
CHANGED
data/lib/locales/de.yml
ADDED
data/lib/locales/en.yml
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bicvalidator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olaf Kaderka
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- ".gitignore"
|
119
119
|
- ".rspec"
|
120
120
|
- ".travis.yml"
|
121
|
+
- Appraisals
|
121
122
|
- CODE_OF_CONDUCT.md
|
122
123
|
- Gemfile
|
123
124
|
- LICENSE.txt
|
@@ -126,8 +127,16 @@ files:
|
|
126
127
|
- bicvalidator.gemspec
|
127
128
|
- bin/console
|
128
129
|
- bin/setup
|
130
|
+
- gemfiles/rails_3.0.gemfile
|
131
|
+
- gemfiles/rails_4.0.gemfile
|
132
|
+
- gemfiles/rails_4.2.gemfile
|
133
|
+
- gemfiles/rails_5.0.gemfile
|
129
134
|
- lib/bicvalidator.rb
|
135
|
+
- lib/bicvalidator/bic.rb
|
136
|
+
- lib/bicvalidator/bic_model_validator.rb
|
130
137
|
- lib/bicvalidator/version.rb
|
138
|
+
- lib/locales/de.yml
|
139
|
+
- lib/locales/en.yml
|
131
140
|
homepage: https://github.com/olafkaderka/bicvalidator/
|
132
141
|
licenses:
|
133
142
|
- MIT
|
@@ -137,6 +146,7 @@ post_install_message:
|
|
137
146
|
rdoc_options: []
|
138
147
|
require_paths:
|
139
148
|
- lib
|
149
|
+
- lib/bicvalidator
|
140
150
|
required_ruby_version: !ruby/object:Gem::Requirement
|
141
151
|
requirements:
|
142
152
|
- - ">="
|