bicvalidator 0.1.3 → 0.1.5

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
  SHA1:
3
- metadata.gz: 82d4b194fd9542db105f28417793c1ab7509596a
4
- data.tar.gz: ae7994ca2142ed3d6215fa0cfeb165bcc009b6de
3
+ metadata.gz: b2b2e8ded8429995e10520a5488304c5b1f64d2c
4
+ data.tar.gz: a14d65598eff53be950c932c06c9534671e283a9
5
5
  SHA512:
6
- metadata.gz: faba57f7de958b26b323fbabd57c3d473d799ba6454d9b7b2c377d8ba3af533a3ff52b846d4224658e08c27e4da2e34c147f32c5df8f7c0c54db72b7327e891b
7
- data.tar.gz: c52eecde0d93095dc6c2c2df32d54e2a8db1272f01b1f4c28f029aabfd7f1e6a7c71a4b726cb4cc03699852f82b034e21e152e3fbb9ff452995f5a0c5cc3c583
6
+ metadata.gz: 94a4c8f15d54e0aca7b5cbbe0fcd6f5b0dc1fa0090ff0c1306d7ae18f3962c8ef990f0e9cdae9086d094ae6ca3133007f46640d29cf10ce4d4c4fb615925092c
7
+ data.tar.gz: d00a3c6b60844c0e711a1d1a4ffbbfdf9f94a56bf27825c97a39a96a97b865e3e43897a513b1ffcd2e12eebcbc1ecd7d3ebd78aa29a6bc4d8851c82fdf671a5d
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Bicvalidator
2
- Mit dem BicValidator kann man eine Validitäsprüfung und Korrektur (Leerzeichen, Groß/Kleinschreibung) von übergebenen BIC werten durchführen um diese zu prüfen bevor man diese weiterverarbeitet.
3
- Neben der Länge des Codes und den möglichen Ländercodes kann man auch überprüfen ob das Land der BIC (4+5 Stelle) am SepaSchema teilnimmt.
4
- Optional kann man den Check auch ausstellen.
2
+ Mit dem BicValidator wird eine BIC gemäß den [ISO9362)(https://de.wikipedia.org/wiki/ISO_9362) Anforderungen geprüft. Zusätzlich wird übeprüft ob die BIC gemäß dem Ländercode im SEPA Raum ist.
5
3
 
4
+ Inspiriert von [boostify/bic_validation](https://github.com/boostify/bic_validation)
6
5
 
7
6
  ## Installation
8
7
 
@@ -28,63 +27,41 @@ In den Bics sind mehr Länder als in den IBANS, denn die französischen und engl
28
27
  * **Bicvalidator.sepa_bic_countries = []**
29
28
 
30
29
  ### Instanz Initialisierung
31
- **Bicvalidator::Validate.new(options={})**
32
-
33
- Das Objekt erwartet nur einen Parameter options als hash in dem man die möglichen vorhanden Wert übergeben kann
34
- * **:bic_code** String mit dem BicCode
35
- * **:bic_bankcode** String lokale BLZ des Landes, (Land muss dann auch kommen)
36
- * **:bic_country** String ISO 3166-1 alpha-2 (2 Stellig)
37
- * **:sepa_country_check** true/false soll direkt überprüft werden ob das land im Separaum ist. **default => true**
38
-
39
- Alle übergeben Werte werden automatsich korrigiert falls möglich (Gross/Klein, Leerzeichen entfernt)
40
- Das Object hat dann folgende Attribute auf die man zugreifen kann:
41
- * **:errorcode, :bic_bankcode, :bic_code, :bic_country, :sepa_country**
30
+ **Bicvalidator::Bic.new(string)**
42
31
 
43
32
  ### Beipiele
44
- **bv = Bicvalidator::Validate.new({:bic_code => " GENODEM 1A HL "})**
45
- * bv.bic_code => "GENODEM1AHL"
46
- * bv.bic_country => "DE"
47
- * bv.errorcode => nil
48
- * bv.sepa_country => true
49
-
50
- **bv = Bicvalidator::Validate.new({:bic_code => "GENNAEXS"})**
51
- * bv.bic_code => "GENNAEXS"
52
- * bv.bic_country => "AE"
53
- * bv.errorcode => "BV0026" (Kein SEPA Land)
54
- * bv.sepa_country => false
55
-
56
- **bv = Bicvalidator::Validate.new({:bic_code => "GENNAEXS", :sepa_country_check => false})**
57
- * bv.bic_code => "GENNAEXS"
58
- * bv.bic_country => "AE"
59
- * bv.errorcode => nil
60
- * bv.sepa_country => false
61
-
33
+ **bv = Bicvalidator::Bic.new(" GENODEM 1A HL ")**
34
+
35
+ bv.errorcode => nil
36
+ bv.bic_code => GENODEM1AHL"
37
+ bv.country => "DE"
38
+ bv.location) => "M1"
39
+ bv.branch) => "AHL"
40
+ bv.sepa_scheme? => true (ist gemäß dem SEPA-Ländercodes im SEPA-Schema Raum)
62
41
 
63
42
 
64
43
  ### Errorcodes
65
-
66
- * "BV0000": BicValidator keine Werte zum überprüfen
67
- * "BV0010": BIC ungültige Zeichen
68
- * "BV0011": BIC ungültige Länge
69
- * "BV0020": BIC Land ungültige Zeichen
70
- * "BV0021": BIC Land ungültige Länge
71
- * "BV0025": BIC Land unbekannt
72
- * "BV0026": BIC Land Kein SEPA Land
73
- * "BV0030": BIC Bankcode ohne Land
74
- * "BV0032": BIC Bankcode undgültige Zeichen (allgemein)
75
- * "BV0040": BIC Bankcode ungültig (länderspezfisch)
76
-
77
-
44
+ Wen man genau wissen will , was der Fehler ist kann man mit bv.errorcode den genauen Wert ermitteln
45
+ "BV0010" if !has_valid_lenght?
46
+ "BV0011" if !has_valid_format?
47
+ "BV0012" if !valid_country_code?
48
+ "BV0013" if !valid_location_code?
49
+ "BV0014" if !valid_branch_code?
78
50
 
79
51
  ### Tests per Rspec
80
- bundle exec rspec spec
52
+ rspec
53
+
54
+ ### Gem Pushing
55
+ gem build bicvalidator.gemspec
56
+ gem push bicvalidator-X.X.X.gem
81
57
 
82
58
  ## Development
83
59
 
84
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
60
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rspec` to run the tests.
85
61
 
86
62
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
87
63
 
64
+
88
65
  ## Contributing
89
66
 
90
67
  Bug reports and pull requests are welcome on GitHub at https://github.com/olafkaderka/bicvalidator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -93,6 +70,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/olafka
93
70
 
94
71
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
95
72
 
96
- ## Code of Conduct
97
-
98
- Everyone interacting in the Bicvalidator project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/olafkaderka/bicvalidator/blob/master/CODE_OF_CONDUCT.md).
data/lib/bicvalidator.rb CHANGED
@@ -1,104 +1,19 @@
1
1
  require "bicvalidator/version"
2
2
  require 'active_support'
3
3
  require 'active_support/core_ext'
4
+ require "bicvalidator/bic"
4
5
  #brauch ich fuer laendercodes ISO3166::Country
5
6
  require 'countries'
6
-
7
- module Bicvalidator
8
-
9
- mattr_accessor :sepa_bic_countries
7
+ module Bicvalidator
8
+ mattr_accessor :sepa_bic_countries
9
+ mattr_accessor :countries
10
+ mattr_accessor :eu_countries
11
+ #mattr_accessor :non_eu_countries
10
12
 
11
13
  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"]
14
+ Bicvalidator.countries = ISO3166::Country.translations.keys
15
+ Bicvalidator.eu_countries = ISO3166::Country.all.select {|it| it.in_eu?}
16
+ #Bicvalidator.non_eu_countries = Bicvalidator.countries - Bicvalidator.eu_countries
12
17
 
13
18
 
14
- class Bic
15
-
16
- attr_accessor :bic_code, :bank, :country, :location, :branch
17
-
18
- def initialize(bic_str)
19
- ##strip reicht nicht denn strip entfernt nur leerzeichen vorne und hinten
20
- @bic_code = bic_str.strip.gsub(/\s+/, '').upcase
21
- end
22
-
23
- def errorcode
24
- return if valid?
25
- return "BV0010" if !has_valid_lenght?
26
- return "BV0011" if !has_valid_format?
27
- return "BV0012" if !valid_country_code?
28
- return "BV0013" if !valid_location_code?
29
- return "BV0014" if !valid_branch_code?
30
- end
31
- #in instanz
32
- def valid?
33
- has_valid_lenght? && has_valid_format? && valid_country_code? && valid_location_code? && valid_branch_code?
34
- end
35
-
36
- def has_valid_lenght?
37
- [8, 11].include? @bic_code.length
38
- end
39
-
40
- def has_valid_format?
41
- !(@bic_code =~ bic_iso_format).nil?
42
- end
43
-
44
- def valid_country_code?
45
- !ISO3166::Country.new(country).nil?
46
- end
47
-
48
- def valid_location_code?
49
- #http://de.wikipedia.org/wiki/ISO_9362
50
- #2-stellige Codierung des Ortes in zwei Zeichen. Das erste Zeichen darf nicht die Ziffer „0“ oder „1“ sein.
51
- #Der Buchstabe 'O' ist als zweites Zeichen nicht gestattet.
52
- !(location[0] =~ /[^01]/ && location[1] =~ /[^O]/).nil?
53
- end
54
-
55
- def valid_branch_code?
56
- #Der Branch-Code darf nicht mit „X“ anfangen, es sei denn, es ist „XXX“.
57
- return true if @bic_code.length == 8
58
- return true if branch == "XXX"
59
- (branch[0] =~ /[X]/).nil?
60
- end
61
-
62
- def sepa_scheme?
63
- valid? and Bicvalidator.sepa_bic_countries.include? country
64
- end
65
-
66
-
67
- def bank
68
- @bank ||= match[1]
69
- end
70
-
71
- def country
72
- @country ||= match[2]
73
- end
74
-
75
- def location
76
- @location ||= match[3]
77
- end
78
-
79
- def branch
80
- @branch ||= match[4]
81
- end
82
-
83
- private
84
-
85
- def bic_iso_format
86
- #https://de.wikipedia.org/wiki/ISO_9362
87
- #BBBB 4-stelliger Bankcode, vom Geldinstitut frei wählbar
88
- #CC 2-stelliger Ländercode nach ISO 3166-1
89
- #LL 2-stellige Codierung des Ortes in zwei Zeichen.
90
- #Das erste Zeichen darf nicht die Ziffer „0“ oder „1“ sein.
91
- #Wenn das zweite Zeichen kein Buchstabe, sondern eine Ziffer ist, so bedeutet dies:
92
- #bbb 3-stellige Kennzeichnung (Branch-Code) der Filiale oder Abteilung (optional)
93
- #test in http://rubular.com/
94
- /([A-Z]{4})([A-Z]{2})([0-9A-Z]{2})([0-9A-Z]{3})?/
95
- end
96
-
97
- def match
98
- bic_iso_format.match(@bic_code)
99
- end
100
-
101
-
102
- end
103
-
104
19
  end
@@ -1,3 +1,3 @@
1
1
  module Bicvalidator
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.5"
3
3
  end
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.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olaf Kaderka