swiss_bank_validator 0.5.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -1
- data/Gemfile.lock +15 -15
- data/README.md +20 -2
- data/changelog.md +8 -0
- data/lib/swiss_bank_validator/constants.rb +4 -0
- data/lib/swiss_bank_validator/locale/de.yml +1 -0
- data/lib/swiss_bank_validator/locale/en.yml +1 -0
- data/lib/swiss_bank_validator/locale/fr.yml +1 -0
- data/lib/swiss_bank_validator/validates_bank_field_of.rb +34 -0
- data/lib/swiss_bank_validator/version.rb +1 -1
- data/lib/swiss_bank_validator.rb +1 -0
- data/swiss_bank_validator.gemspec +2 -1
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e732c6d7af46cf6b17975478adcfc45bdfb572b8e97bdf24cb89a085b505bc71
|
4
|
+
data.tar.gz: abd64659b420eded239358187044a45de8ce27968705f5b142a9f80115616bed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46c8f70ecc5a87afad4cc1d3732f9fffa65e842469e489c203d968a947c4d974610b36a34cba4c2bfbf2535e15660c225963a0246f2aac7ca747fc9bf6130684
|
7
|
+
data.tar.gz: e6866ccc50eab3f193efc7f0fe8ee6ced05ec982c643f55b4108385ca52ecb41a995ebb5bb625dc9c5d90480d0d29b316a9e3bef5e6b3ae985755c71fd64e425
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,33 +1,34 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
swiss_bank_validator (0.
|
4
|
+
swiss_bank_validator (0.6.1)
|
5
5
|
activemodel (~> 6.0)
|
6
|
+
rexml (~> 3.2.5)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
10
|
-
activemodel (6.
|
11
|
-
activesupport (= 6.
|
12
|
-
activesupport (6.
|
11
|
+
activemodel (6.1.3.2)
|
12
|
+
activesupport (= 6.1.3.2)
|
13
|
+
activesupport (6.1.3.2)
|
13
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
-
i18n (>=
|
15
|
-
minitest (
|
16
|
-
tzinfo (~>
|
17
|
-
zeitwerk (~> 2.
|
15
|
+
i18n (>= 1.6, < 2)
|
16
|
+
minitest (>= 5.1)
|
17
|
+
tzinfo (~> 2.0)
|
18
|
+
zeitwerk (~> 2.3)
|
18
19
|
ast (2.4.1)
|
19
|
-
concurrent-ruby (1.1.
|
20
|
+
concurrent-ruby (1.1.8)
|
20
21
|
diff-lcs (1.4.4)
|
21
|
-
i18n (1.8.
|
22
|
+
i18n (1.8.10)
|
22
23
|
concurrent-ruby (~> 1.0)
|
23
|
-
minitest (5.14.
|
24
|
+
minitest (5.14.4)
|
24
25
|
parallel (1.20.1)
|
25
26
|
parser (2.7.2.0)
|
26
27
|
ast (~> 2.4.1)
|
27
28
|
rainbow (3.0.0)
|
28
29
|
rake (12.3.3)
|
29
30
|
regexp_parser (2.0.0)
|
30
|
-
rexml (3.2.
|
31
|
+
rexml (3.2.5)
|
31
32
|
rspec (3.10.0)
|
32
33
|
rspec-core (~> 3.10.0)
|
33
34
|
rspec-expectations (~> 3.10.0)
|
@@ -53,9 +54,8 @@ GEM
|
|
53
54
|
rubocop-ast (1.3.0)
|
54
55
|
parser (>= 2.7.1.5)
|
55
56
|
ruby-progressbar (1.10.1)
|
56
|
-
|
57
|
-
|
58
|
-
thread_safe (~> 0.1)
|
57
|
+
tzinfo (2.0.4)
|
58
|
+
concurrent-ruby (~> 1.0)
|
59
59
|
unicode-display_width (1.7.0)
|
60
60
|
zeitwerk (2.4.2)
|
61
61
|
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Allow to valid a Swiss Iban passed on the rules of http://www.swissiban.com/
|
4
4
|
|
5
|
+
You can also validate field to be complient with bank (without special character). Useful if you want to create batch paiement
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
@@ -20,6 +22,8 @@ Or install it yourself as:
|
|
20
22
|
|
21
23
|
## Usage
|
22
24
|
|
25
|
+
To validate an IBAN
|
26
|
+
|
23
27
|
```ruby
|
24
28
|
class Account < ActiveRecord::Base
|
25
29
|
validates_iban_format_of :account_number
|
@@ -32,6 +36,20 @@ Or install it yourself as:
|
|
32
36
|
end
|
33
37
|
```
|
34
38
|
|
39
|
+
To validate a bank field
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
class Account < ActiveRecord::Base
|
43
|
+
validates_bank_field_of :name
|
44
|
+
end
|
45
|
+
|
46
|
+
# or
|
47
|
+
|
48
|
+
class Account < ActiveRecord::Base
|
49
|
+
validates :name, bank_field: true
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
35
53
|
## Development
|
36
54
|
|
37
55
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -40,7 +58,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
40
58
|
|
41
59
|
## Contributing
|
42
60
|
|
43
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
61
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/qoqa/swiss_bank_validator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/qoqa/swiss_bank_validator/blob/master/CODE_OF_CONDUCT.md).
|
44
62
|
|
45
63
|
|
46
64
|
## License
|
@@ -49,4 +67,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
49
67
|
|
50
68
|
## Code of Conduct
|
51
69
|
|
52
|
-
Everyone interacting in the SwissBankValidator project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
70
|
+
Everyone interacting in the SwissBankValidator project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/qoqa/iban_validator/blob/master/CODE_OF_CONDUCT.md).
|
data/changelog.md
CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [0.6.1]
|
9
|
+
|
10
|
+
- Fix Rexml vulnerabilities
|
11
|
+
|
12
|
+
## [0.6.0]
|
13
|
+
|
14
|
+
- Add validation for bank field that not accept special char
|
15
|
+
|
8
16
|
## [0.5.1]
|
9
17
|
|
10
18
|
- Change FR translation
|
@@ -3,4 +3,8 @@
|
|
3
3
|
module SwissBankValidator
|
4
4
|
IBAN_REGEX = /\ACH[A-Z0-9]{2}\d{5}[A-Z0-9]{12}\z/.freeze
|
5
5
|
IBAN_LENGTH = 21
|
6
|
+
|
7
|
+
# Regex that allow only field accepted by Swiss bank to initiate a payment
|
8
|
+
BANK_REGEX = %r{\A[a-zA-Z0-9.,;:’+\-()?*\[\]{}`´~'\s!“#%÷=@_$£
|
9
|
+
àáâäçèéêëìíîïñòóôöùúûüýßÀÁÂÄÇÈÉÊËÌÍÎÏÒÓÔÖÙÚÛÜÑ]*\z}x.freeze
|
6
10
|
end
|
@@ -6,6 +6,7 @@ de:
|
|
6
6
|
space_not_authorized_in_iban: Abstände sind nicht zugelassen.
|
7
7
|
iban_format_not_valid: Das Format der angegebenen IBAN ist nicht gültig.
|
8
8
|
must_start_with_ch: "Beginnt mit CH"
|
9
|
+
invalid_bank_field: Sonderzeichen (&/<>°\|...) sind nicht erlaubt.
|
9
10
|
|
10
11
|
activerecord:
|
11
12
|
<<: *activemodel
|
@@ -6,6 +6,7 @@ en:
|
|
6
6
|
space_not_authorized_in_iban: "Spaces are not authorized"
|
7
7
|
iban_format_not_valid: "Your IBAN format is not valid"
|
8
8
|
must_start_with_ch: "Must start with CH"
|
9
|
+
invalid_bank_field: Not a valid Bank field. It does not accept special character (&/<>°\|...)
|
9
10
|
|
10
11
|
activerecord:
|
11
12
|
<<: *activemodel
|
@@ -6,6 +6,7 @@ fr:
|
|
6
6
|
space_not_authorized_in_iban: "Les espaces ne sont pas autorisés"
|
7
7
|
iban_format_not_valid: "Le format de l'IBAN n'est pas valide"
|
8
8
|
must_start_with_ch: "doit commencer par CH"
|
9
|
+
invalid_bank_field: Ce champ n'accepte pas certains caractères spéciaux (&/<>°\|...)
|
9
10
|
|
10
11
|
activerecord:
|
11
12
|
<<: *activemodel
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveModel
|
4
|
+
module Validations
|
5
|
+
class BankFieldValidator < EachValidator
|
6
|
+
def validate_each(record, attribute, value)
|
7
|
+
return if value.blank? && options[:allow_blank]
|
8
|
+
return if value.nil? && options[:allow_nil]
|
9
|
+
|
10
|
+
return if value.to_s =~ SwissBankValidator::BANK_REGEX
|
11
|
+
|
12
|
+
record.errors.add(
|
13
|
+
attribute,
|
14
|
+
:invalid_bank_field,
|
15
|
+
message: options[:message]
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module ClassMethods
|
21
|
+
# Validates whether or not the specified field bank complient.
|
22
|
+
#
|
23
|
+
# class Account < ActiveRecord::Base
|
24
|
+
# validates_bank_field_of :name
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
def validates_bank_field_of(*attr_names)
|
28
|
+
validates_with BankFieldValidator, _merge_attributes(attr_names)
|
29
|
+
end
|
30
|
+
|
31
|
+
alias validates_bank_field validates_bank_field_of
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/swiss_bank_validator.rb
CHANGED
@@ -4,6 +4,7 @@ module SwissBankValidator
|
|
4
4
|
require 'swiss_bank_validator/version'
|
5
5
|
require 'swiss_bank_validator/constants'
|
6
6
|
require 'swiss_bank_validator/validates_iban_format_of'
|
7
|
+
require 'swiss_bank_validator/validates_bank_field_of'
|
7
8
|
|
8
9
|
I18n.load_path += Dir[File.join(__dir__, 'swiss_bank_validator/locale/*.yml')]
|
9
10
|
end
|
@@ -27,7 +27,8 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ['lib']
|
29
29
|
|
30
|
-
spec.add_dependency 'activemodel', '
|
30
|
+
spec.add_dependency 'activemodel', '>= 6.0'
|
31
|
+
spec.add_dependency 'rexml', '~> 3.2.5'
|
31
32
|
|
32
33
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
34
|
spec.add_development_dependency 'rubocop', '~> 1.5'
|
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swiss_bank_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- QoQa dev Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '6.0'
|
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
26
|
version: '6.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rexml
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.2.5
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.2.5
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rspec
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,6 +91,7 @@ files:
|
|
77
91
|
- lib/swiss_bank_validator/locale/de.yml
|
78
92
|
- lib/swiss_bank_validator/locale/en.yml
|
79
93
|
- lib/swiss_bank_validator/locale/fr.yml
|
94
|
+
- lib/swiss_bank_validator/validates_bank_field_of.rb
|
80
95
|
- lib/swiss_bank_validator/validates_iban_format_of.rb
|
81
96
|
- lib/swiss_bank_validator/version.rb
|
82
97
|
- swiss_bank_validator.gemspec
|
@@ -102,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
117
|
- !ruby/object:Gem::Version
|
103
118
|
version: '0'
|
104
119
|
requirements: []
|
105
|
-
rubygems_version: 3.1.
|
120
|
+
rubygems_version: 3.1.2
|
106
121
|
signing_key:
|
107
122
|
specification_version: 4
|
108
123
|
summary: All you need to validate a Swiss Iban
|