banktools-gb 0.3.0 → 0.4.0

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: 65cd1f379a4a88b8b1365b95bfecbb7461f21c61
4
- data.tar.gz: caec31edbf9e34108af0e4d1a977ef7144d65e0e
3
+ metadata.gz: e62708dc1891a4ffa3ff2cd58a02e3fb4f5eaa9d
4
+ data.tar.gz: 408c21b0d050f697b137090a1b291b948a6f0648
5
5
  SHA512:
6
- metadata.gz: bec40e93a58ff5b5022ea6410779b68d1909564d48f0a8e4159c66965298218e370cfd0b9127e8862af89753119f222a34ba1ee7e689bcd8e8c6977d1bd65172
7
- data.tar.gz: 115241193ae89b1099e24328264bad1d6cd875c2640916be9e7b5891a575d6ebd1096060bcddfb57fc94b3ecfa7ea1f59b26e54cff3a331e3a4c34cce3ccd264
6
+ metadata.gz: d5910eeb5b48f599ecd3e2a964a7cc9741cad0bcaefcee22c85d7e6b5e49f733239a2923f9d04118c0dd1c8d4a84e23b7399f89ff5ca70ce5cedcfd8ceadd933
7
+ data.tar.gz: 040d89b34757aa5c4f8c86a9a3f71c487a697dd6233d46085f975e4d8b8d0ed5b50576b0762eb359a885250b0f53e27426057e573666bb8940ff5ebe4f4c0557
data/.travis.yml CHANGED
@@ -4,4 +4,3 @@ rvm:
4
4
  - 2.2.0
5
5
  - 2.1.0
6
6
  - 2.0.0
7
- - 1.9.3
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/barsoom/banktools-gb.svg?branch=master)](https://travis-ci.org/barsoom/banktools-gb)
4
4
 
5
- Ruby gem to validate and normalize United Kingdom bank account numbers.
5
+ Ruby gem to validate United Kingdom bank account numbers.
6
6
 
7
7
  If we got anything wrong, please file an issue or contribute a fix yourself.
8
8
 
@@ -14,7 +14,7 @@ If we got anything wrong, please file an issue or contribute a fix yourself.
14
14
 
15
15
  bad_account = BankTools::GB::AccountNumberWithSortCode.new(account_number: "1", sort_code: "")
16
16
  bad_account.valid? # => false
17
- bad_account.errors # => [:too_short]
17
+ bad_account.errors # => [:account_numberaccount_number_too_short]
18
18
 
19
19
  # Error codes
20
20
 
@@ -13,7 +13,7 @@ module BankTools
13
13
  pattr_initialize [ :account_number, :sort_code ]
14
14
 
15
15
  def valid?
16
- UkAccountValidator::Validator.new(compact_account_number, compact_sort_code).valid?
16
+ errors.none?
17
17
  end
18
18
 
19
19
  def errors
@@ -23,11 +23,16 @@ module BankTools
23
23
  errors << :sort_code_with_wrong_length if sort_code_with_wrong_length?
24
24
  errors << :sort_code_invalid_characters if any_non_digits?(compact_sort_code)
25
25
  errors << :account_number_invalid_characters if any_non_digits?(compact_account_number)
26
+ errors << :account_number_does_not_match_sort_code unless valid_account_number_with_sort_code?
26
27
  errors
27
28
  end
28
29
 
29
30
  private
30
31
 
32
+ def valid_account_number_with_sort_code?
33
+ UkAccountValidator::Validator.new(compact_account_number, compact_sort_code).valid?
34
+ end
35
+
31
36
  def sort_code_with_wrong_length?
32
37
  compact_sort_code.length != SORT_CODE_LENGTH
33
38
  end
@@ -1,11 +1,12 @@
1
1
  module Banktools
2
2
  module GB
3
3
  module Errors
4
- ACCOUNT_NUMBER_TOO_SHORT = :account_number_too_short
5
- ACCOUNT_NUMBER_TOO_LONG = :account_number_too_long
6
- SORT_CODE_WITH_WRONG_LENGTH = :sort_code_with_wrong_length
7
- SORT_CODE_INVALID_CHARACTERS = :sort_code_invalid_characters
8
- ACCOUNT_NUMBER_INVALID_CHARACTERS = :account_number_invalid_characters
4
+ ACCOUNT_NUMBER_TOO_SHORT = :account_number_too_short
5
+ ACCOUNT_NUMBER_TOO_LONG = :account_number_too_long
6
+ SORT_CODE_WITH_WRONG_LENGTH = :sort_code_with_wrong_length
7
+ SORT_CODE_INVALID_CHARACTERS = :sort_code_invalid_characters
8
+ ACCOUNT_NUMBER_INVALID_CHARACTERS = :account_number_invalid_characters
9
+ ACCOUNT_NUMBER_DOES_NOT_MATCH_SORT_CODE = :account_number_does_not_match_sort_code
9
10
  end
10
11
  end
11
12
  end
@@ -1,5 +1,5 @@
1
1
  module Banktools
2
2
  module Gb
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: banktools-gb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Skogberg