iban_bic 1.4.0 → 1.4.5
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 +4 -4
- data/README.md +28 -12
- data/lib/active_model/validations/bic_validator.rb +3 -3
- data/lib/active_model/validations/iban_validator.rb +2 -0
- data/lib/generators/iban_bic/install_generator.rb +1 -1
- data/lib/iban_bic/configuration.rb +2 -2
- data/lib/iban_bic/core.rb +2 -2
- data/lib/iban_bic/version.rb +1 -1
- metadata +11 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f2651f4f3ff003d3c6e37078d480f835358165dd
|
|
4
|
+
data.tar.gz: cd2a59c0312bc577ff3f569c3de46b65f0025257
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 331416989965fa9b86b67f362e56aff8e84eda9830be2a3b81223b503ae4440ef90b1e582cd23df1153f0eb05fc338f11b070a44129a9f9e5439a1bedbc15242
|
|
7
|
+
data.tar.gz: 4bd37ec79d8a815369e41d044f159a466cce55376eeb18ff795e339602e33374caa1abf887a45b04700c9f810dda5c1118bdb53bf4e5b5be90a821be605e42bd
|
data/README.md
CHANGED
|
@@ -47,52 +47,52 @@ validates :bic, bic: { country: :pais }
|
|
|
47
47
|
3. IBAN control digits calculation
|
|
48
48
|
|
|
49
49
|
```ruby
|
|
50
|
-
|
|
50
|
+
IbanBic.calculate_check("ES0000030000300000000000")
|
|
51
51
|
=> 87
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
4. IBAN parsing
|
|
55
55
|
|
|
56
56
|
```ruby
|
|
57
|
-
|
|
57
|
+
IbanBic.parse("ES8700030000300000000000")
|
|
58
58
|
=> {"country"=>"ES", "iban_check"=>"87", "bank"=>"0003", "branch"=>"0000", "check"=>"30", "account"=>"0000000000"}
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
5. IBAN fixing (IBAN control digits and country control digits, if that code is available)
|
|
62
62
|
|
|
63
63
|
```ruby
|
|
64
|
-
|
|
64
|
+
IbanBic.fix("ES0000030000200000000000")
|
|
65
65
|
=> "ES8700030000300000000000"
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
6. BIC calculation (bank code must be in the static file or in the database)
|
|
69
69
|
|
|
70
70
|
```ruby
|
|
71
|
-
|
|
71
|
+
IbanBic.calculate_bic("ES8700030000300000000000")
|
|
72
72
|
=> "BDEPESM1XXX"
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
7. Pattern generation for SQL LIKE queries.
|
|
76
76
|
|
|
77
77
|
```ruby
|
|
78
|
-
|
|
78
|
+
IbanBic.like_pattern("ES8700030000300000000000", :country, :bank)
|
|
79
79
|
=> "ES__0003________________"
|
|
80
|
-
|
|
80
|
+
IbanBic.like_pattern_from_parts(country: "ES", bank: "0003")
|
|
81
81
|
=> "ES__0003________________"
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
8. Random IBAN generation
|
|
85
85
|
|
|
86
86
|
```ruby
|
|
87
|
-
|
|
87
|
+
require "iban_bic/random"
|
|
88
88
|
=> true
|
|
89
|
-
|
|
89
|
+
IbanBic.random_iban
|
|
90
90
|
=> "MU52BOIR2768144336487102000AWQ"
|
|
91
|
-
|
|
91
|
+
IbanBic.random_iban country: "ES"
|
|
92
92
|
=> "ES6111051493192369291292"
|
|
93
|
-
|
|
93
|
+
IbanBic.random_iban tags: [:sepa]
|
|
94
94
|
=> "FI5584518206233159"
|
|
95
|
-
|
|
95
|
+
IbanBic.random_iban not_tags: [:sepa]
|
|
96
96
|
=> "IL317532867920826062774"
|
|
97
97
|
```
|
|
98
98
|
|
|
@@ -132,7 +132,7 @@ $ bundle exec rake iban_bic:load_data
|
|
|
132
132
|
3.b. Using static data from YAML files
|
|
133
133
|
|
|
134
134
|
Create an initializer file for configuration:
|
|
135
|
-
|
|
135
|
+
|
|
136
136
|
```bash
|
|
137
137
|
$ bundle exec rails generate iban_bic:install --with-static-data
|
|
138
138
|
```
|
|
@@ -140,6 +140,22 @@ $ bundle exec rails generate iban_bic:install --with-static-data
|
|
|
140
140
|
4. Customize initializer if needed, adding validations for new countries, or overriding YAML files.
|
|
141
141
|
|
|
142
142
|
## Changelog
|
|
143
|
+
#### 1.4.4
|
|
144
|
+
|
|
145
|
+
* Support for Rails 5.2.
|
|
146
|
+
|
|
147
|
+
#### 1.4.3
|
|
148
|
+
|
|
149
|
+
* Fixed validators to avoid failing when values are `nil`.
|
|
150
|
+
|
|
151
|
+
#### 1.4.2
|
|
152
|
+
|
|
153
|
+
* Dependencies security update.
|
|
154
|
+
|
|
155
|
+
#### 1.4.1
|
|
156
|
+
|
|
157
|
+
* Fixed BIC validation, don't allow less 1 or 2 characters for the office code and don't allow to add extra characters at the begining or at the end of the string.
|
|
158
|
+
|
|
143
159
|
#### 1.4.0
|
|
144
160
|
|
|
145
161
|
* BIC validation moved from BIC model to an independent validator.
|
|
@@ -9,10 +9,10 @@ module ActiveModel
|
|
|
9
9
|
module Validations
|
|
10
10
|
class BicValidator < ActiveModel::EachValidator
|
|
11
11
|
def validate_each(record, attribute, value)
|
|
12
|
+
return unless value.present?
|
|
13
|
+
|
|
12
14
|
country_field = options[:country] ? record[options[:country]] : "[A-Z]{2}"
|
|
13
|
-
unless
|
|
14
|
-
record.errors.add(attribute, :invalid_format)
|
|
15
|
-
end
|
|
15
|
+
record.errors.add(attribute, :invalid_format) unless /^[A-Z]{4}#{country_field}[0-9A-Z]{2}([0-9A-Z]{3})?$/.match? value.upcase
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
end
|
|
@@ -9,6 +9,8 @@ module ActiveModel
|
|
|
9
9
|
module Validations
|
|
10
10
|
class IbanValidator < ActiveModel::EachValidator
|
|
11
11
|
def validate_each(record, attribute, value)
|
|
12
|
+
return unless value.present?
|
|
13
|
+
|
|
12
14
|
if !IbanBic.parse(value)
|
|
13
15
|
record.errors.add(attribute, :invalid_format)
|
|
14
16
|
elsif !IbanBic.valid_check?(value)
|
|
@@ -8,7 +8,7 @@ module IbanBic
|
|
|
8
8
|
class InstallGenerator < ::Rails::Generators::Base
|
|
9
9
|
include ::Rails::Generators::Migration
|
|
10
10
|
|
|
11
|
-
source_root File.expand_path("
|
|
11
|
+
source_root File.expand_path("templates", __dir__)
|
|
12
12
|
|
|
13
13
|
class_option(
|
|
14
14
|
:with_static_bics,
|
|
@@ -4,8 +4,8 @@ module IbanBic
|
|
|
4
4
|
class Configuration
|
|
5
5
|
attr_accessor :iban_meta_path, :use_static_bics, :bics_table_name, :static_bics_path
|
|
6
6
|
|
|
7
|
-
def add(country)
|
|
8
|
-
IbanBic.country_validators[country] =
|
|
7
|
+
def add(country, &block)
|
|
8
|
+
IbanBic.country_validators[country] = block
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def static_bics?
|
data/lib/iban_bic/core.rb
CHANGED
data/lib/iban_bic/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: iban_bic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.4.
|
|
4
|
+
version: 1.4.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Leonardo Diez
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-06-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '6.1'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '6.1'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: regexp-examples
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -72,42 +72,42 @@ dependencies:
|
|
|
72
72
|
requirements:
|
|
73
73
|
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
75
|
+
version: '5.0'
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
82
|
+
version: '5.0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: rubocop
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
87
|
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version:
|
|
89
|
+
version: 0.63.0
|
|
90
90
|
type: :development
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
|
-
version:
|
|
96
|
+
version: 0.63.0
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
98
|
name: sqlite3
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
101
|
- - "~>"
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version:
|
|
103
|
+
version: 1.4.2
|
|
104
104
|
type: :development
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version:
|
|
110
|
+
version: 1.4.2
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
112
|
name: virtus
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
169
169
|
version: '0'
|
|
170
170
|
requirements: []
|
|
171
171
|
rubyforge_project:
|
|
172
|
-
rubygems_version: 2.
|
|
172
|
+
rubygems_version: 2.5.2.1
|
|
173
173
|
signing_key:
|
|
174
174
|
specification_version: 4
|
|
175
175
|
summary: IBAN and BIC tools for Rails applications
|