ibanvalidator 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef40528d9257eeb9f757f077d3dcb48528705306
4
- data.tar.gz: d0df34bcb21e7fa0260a2eb7aa4413caae0cd2a9
3
+ metadata.gz: 9c562e97a04982ee523d2601adbcdb38221e6248
4
+ data.tar.gz: 5cd4d0a92482a156efd5123f3e8358e75ae1d84b
5
5
  SHA512:
6
- metadata.gz: 4774641ad2a413d328b64b5a6e8589d6ab35bfed46e337e6518c215dfbcb96429492d63e32a29f2b6f91b594f87f533e9f30119dee97d7b622027fcff6fe5eef
7
- data.tar.gz: 3f9c45b458d1c313b162631e0cc153dfce61d965786f3dfe19b922aef3729b9cb072c9a1bb15283a227f59cfc9fca5145bca3455aa00e3b91ab6e1b28b492d95
6
+ metadata.gz: 551e9feff006ea6a96917a29dc179fde9db4a8ee87b0e10b3d3a630edf9105c7e06f875468b7fa0f222f0a368a09c2f29c22232166aa0b6f21345d3400eabdb1
7
+ data.tar.gz: 8611a23668c2d5d04183b8a61c64d51e6caaf62a6d9d0f325f9d2076a596e363b7b4f6a94ba7f909da6a213f8f9f6fc0cee66acc095c87334334972fd7b44aeb
data/README.md CHANGED
@@ -36,23 +36,39 @@ Or install it yourself as:
36
36
  iban.code => "DE89370400440532013000"
37
37
  iban.bban => "370400440532013000"
38
38
  iban.country_code => "DE"
39
- iban.to_local => {bank_code: '37040044', account_number: '532013000'}
40
39
  iban.check_digits => "89"
41
40
  iban.prettify => "DE89 3704 0044 0532 0130 00"
42
41
  iban.sepa_scheme? => true
43
42
 
43
+ iban.to_local => {bank_code: '37040044', account_number: '532013000'} => standarmässig ohne führende Null
44
+
45
+ iban = Ibanvalidator::IBAN.new("ES9121000418450200051332")
46
+ iban.to_local => {:bank_code=>"2100", :branch_code=>"418", :check_digits=>"45", :account_number=>"2000513"} => ohne führende Nullen
47
+ iban.to_local**(false)** => {:bank_code=>"2100", :branch_code=>"0418", :check_digits=>"45", :account_number=>"02000513"} => mit führende Nullen
48
+
49
+
50
+ ### erroors
51
+ iban.errors => liefert ein array mit den möglichen Fehlern
52
+ * :iban_too_short, :iban_too_short, :iban_bad_chars => sind grundsätzliche Fehler
53
+ * :iban_unknown_country_code, :iban_bad_length, :iban_bad_format, :iban_bad_check_digits => sind Regel-Fehler (also landesspezifisch)
54
+
44
55
 
56
+ ## Constants/Initits
45
57
 
46
- Ibanvalidator.default_rules, liefert alle IBAN Regeln
47
- **Ibanvalidator.rule_countries**, liefert ein Array mit allen Ländern für die eine Rule hinterlegt ist
48
- => ["AD", "AE", "AL", "AT", "AZ", "BA", "BE", "BG", "BH", "BR", "CH", "CY", "CZ", "DE", "DK", "DO", "EE", "ES", "FI", "FO", "FR", "GB", "GE", "GI", "GL", "GR", "HR", "HU", "IE", "IL", "IS", "IT", "JO", "KW", "KZ", "LB", "LI", "LT", "LU", "LV", "MC", "MD", "ME", "MK", "MR", "MT", "MU", "NL", "NO", "PK", "PL", "PT", "PS", "QA", "RO", "RS", "SA", "SE", "SI", "SK", "SM", "TN", "TR", "UA", "VG"]
58
+ **Ibanvalidator.default_rules** => liefert alle IBAN Regeln
59
+
60
+ **Ibanvalidator.rule_countries** => liefert ein Array mit allen Ländern für die eine Rule hinterlegt ist
61
+ => ["AD", "AE", "AL", "AT", "AZ", "BA", "BE" .... "VG"]
62
+
63
+ **Ibanvalidator.sepa_countries** liefert alle Länder die im Sepa Raum liegen (grundlage für sepa_scheme?)
49
64
 
50
- **Ibanvalidator.sepa_countries** liefert alle Länder die im Sepa Raum liegen
51
65
 
52
66
  ### ActiveRecord/Model Validator
53
- Man kann auch den Model Validator einbinden. Die Felhermeldung sind übersetzt in deutsch und englisch siehe /locales
67
+ Man kann auch den Model Validator einbinden. Die Fehlermeldungen sind übersetzt in deutsch und englisch siehe [/locales](https://github.com/olafkaderka/ibanvalidator/tree/master/lib/locales)
54
68
 
55
69
  validates :iban, iban_model: true
70
+
71
+ locales:
56
72
  de:
57
73
  errors:
58
74
  messages:
@@ -22,9 +22,11 @@ module Ibanvalidator
22
22
  end
23
23
 
24
24
 
25
- def self.iban2local(country_code, bban)
25
+ def self.iban2local(country_code, bban, ignore_zero = true)
26
26
  config = load_config country_code
27
27
 
28
+
29
+
28
30
  local = {}
29
31
  config.map do |key, values|
30
32
  local[key.to_sym] = [values].flatten.map do |value|
@@ -33,7 +35,8 @@ module Ibanvalidator
33
35
  bban.sub! regexp, ''
34
36
  ret
35
37
  end.join('')
36
- local[key.to_sym].sub!(/^0+/, '')
38
+ #entefernen von führenden nullen
39
+ local[key.to_sym].sub!(/^0+/, '') if ignore_zero
37
40
  local[key.to_sym] = '0' if local[key.to_sym] == ''
38
41
  end
39
42
  local
@@ -60,9 +60,9 @@ module Ibanvalidator
60
60
  Conversion.local2iban country_code, data
61
61
  end
62
62
 
63
-
64
- def to_local
65
- Conversion.iban2local country_code, bban
63
+ #mit ignore_zero fasle werdnen die führenden nullen mit ausgegeben
64
+ def to_local(ignore_zero=true)
65
+ Conversion.iban2local country_code, bban, ignore_zero
66
66
  end
67
67
 
68
68
  def to_s
@@ -1,3 +1,3 @@
1
1
  module Ibanvalidator
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibanvalidator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olaf Kaderka