validates_iban 0.0.2 → 0.0.3

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: abba868d56a32e2489832c984af04473b1a148bb
4
- data.tar.gz: 89f4ad424096d3307586db82e2040fa87e1d1eb8
3
+ metadata.gz: e0573a41747d77c47dbcce6d2c3af52dbc09429f
4
+ data.tar.gz: 8770e57b755962877af690b18a970ca404eac7fc
5
5
  SHA512:
6
- metadata.gz: 8b13ceae394d7522f4c9643dd0523b73d687d380bf3a31b861d75c874015af570ea511cd11e60049df596500958aa9a10cda47ccd318a2bb259bdd4ce5b58260
7
- data.tar.gz: 6cf97e93a423f9651523c4687e5b73544add65149e81be08149406b880232a819fd470ab0de92f1546c8573d5d2e793826172ccccd0eb04b7a2a4b32fbee0985
6
+ metadata.gz: 97c3723c342c67f994d46359c96b0c7107d002e573f40124dbcd58e031e27d8ee9ee1fd53c9c6fbae9b52cc16e7023621f5431ddbd3528e77617bfd57bb7ba0a
7
+ data.tar.gz: f45ba247dde4e1420bac9d45310d3b67eb3c3faa84046700fca4e84897864b1a0dfe4668b7c22ab5dddc8f957d159ad0048257d0b149cb9c689b965043fbd597
data/README.md CHANGED
@@ -1,7 +1,3 @@
1
- [![Build Status](https://api.shippable.com/projects/54a7b728d46935d5fbc15f77/badge?branchName=master)](https://app.shippable.com/projects/54a7b728d46935d5fbc15f77/builds/latest)
2
- [![Code Climate](https://codeclimate.com/github/kaspernj/validates_iban/badges/gpa.svg)](https://codeclimate.com/github/kaspernj/validates_iban)
3
- [![Test Coverage](https://codeclimate.com/github/kaspernj/validates_iban/badges/coverage.svg)](https://codeclimate.com/github/kaspernj/validates_iban)
4
-
5
1
  # ValidatesIban
6
2
 
7
3
  ActiveRecord validator for IBAN codes using this project to do the actual validation:
@@ -21,7 +17,7 @@ gem "validates_iban"
21
17
  ## Usage
22
18
 
23
19
  ```ruby
24
- class Account < ActiveRecord::Base
25
- validates :iban_string, iban_field: true
20
+ class Account < ApplicationRecord
21
+ validates :iban_string, iban: true
26
22
  end
27
23
  ```
@@ -1,12 +1,27 @@
1
- require "iban-tools"
1
+ require 'iban-tools'
2
2
 
3
3
  class IbanValidator < ActiveModel::EachValidator
4
4
  def validate_each(object, attribute, value)
5
5
  iban = IBANTools::IBAN.new(value)
6
6
  validation_errors = iban.validation_errors
7
7
 
8
- unless validation_errors.empty?
9
- object.errors[attribute] << (options[:message] || "is not a valid IBAN string: #{validation_errors.join(", ")}")
8
+ object.errors[attribute] << (options[:message] || error_string(validation_errors)) unless validation_errors.empty?
9
+ end
10
+
11
+ private
12
+
13
+ def error_string(validation_errors)
14
+ string = I18n.t('iban.validation.default_message', default: 'is not a valid IBAN string: ')
15
+ validation_errors = validation_errors.map do |error|
16
+ case error.to_sym
17
+ when :too_short then I18n.t('iban.validation.too_short', default: 'too short')
18
+ when :bad_chars then I18n.t('iban.validation.bad_chars', default: 'bad chars')
19
+ when :bad_check_digits then I18n.t('iban.validation.bad_check_digits', default: 'bad check digits')
20
+ when :unknown_country_code then I18n.t('iban.validation.unknown_country_code', default: 'unknown country code')
21
+ when :bad_length then I18n.t('iban.validation.bad_length', default: 'bad length')
22
+ when :bad_format then I18n.t('iban.validation.bad_format', default: 'bad format')
23
+ end
10
24
  end
25
+ string << validation_errors.join(', ').to_s
11
26
  end
12
27
  end
@@ -1,3 +1,3 @@
1
1
  module ValidatesIban
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_iban
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Johansen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-09 00:00:00.000000000 Z
11
+ date: 2018-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,48 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: sqlite3
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec-rails
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: codeclimate-test-reporter
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
41
  description: IBAN validator for ActiveRecord attributes.
84
42
  email:
85
43
  - k@spernj.org
@@ -112,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
70
  version: '0'
113
71
  requirements: []
114
72
  rubyforge_project:
115
- rubygems_version: 2.4.0
73
+ rubygems_version: 2.6.13
116
74
  signing_key:
117
75
  specification_version: 4
118
76
  summary: IBAN validator for ActiveRecord attributes.