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 +4 -4
- data/.travis.yml +0 -1
- data/README.md +2 -2
- data/lib/banktools-gb/account_number_with_sort_code.rb +6 -1
- data/lib/banktools-gb/errors.rb +6 -5
- data/lib/banktools-gb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e62708dc1891a4ffa3ff2cd58a02e3fb4f5eaa9d
|
4
|
+
data.tar.gz: 408c21b0d050f697b137090a1b291b948a6f0648
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5910eeb5b48f599ecd3e2a964a7cc9741cad0bcaefcee22c85d7e6b5e49f733239a2923f9d04118c0dd1c8d4a84e23b7399f89ff5ca70ce5cedcfd8ceadd933
|
7
|
+
data.tar.gz: 040d89b34757aa5c4f8c86a9a3f71c487a697dd6233d46085f975e4d8b8d0ed5b50576b0762eb359a885250b0f53e27426057e573666bb8940ff5ebe4f4c0557
|
data/.travis.yml
CHANGED
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
|
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 # => [:
|
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
|
-
|
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
|
data/lib/banktools-gb/errors.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module Banktools
|
2
2
|
module GB
|
3
3
|
module Errors
|
4
|
-
ACCOUNT_NUMBER_TOO_SHORT
|
5
|
-
ACCOUNT_NUMBER_TOO_LONG
|
6
|
-
SORT_CODE_WITH_WRONG_LENGTH
|
7
|
-
SORT_CODE_INVALID_CHARACTERS
|
8
|
-
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
|
data/lib/banktools-gb/version.rb
CHANGED