banktools-gb 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -6
- data/lib/banktools-gb/account_number_with_sort_code.rb +6 -6
- data/lib/banktools-gb/errors.rb +4 -4
- 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: c0f3e7f61bc8d6f56034536be0c064e6cf1f7d18
|
4
|
+
data.tar.gz: bb3a03b154524de3daed3de0d75513236b4541c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a57461e8877d93410799c501e87d06cd995d9c92519f29731d3fdcef79c3450d43a0b23f2f4a0d8a149d5d7f9248ee711b15f7731de935855d51372abbf470a
|
7
|
+
data.tar.gz: f7e80fe6f3758b54ab86cd6f452172537fa0f684517313cce0b619a8b84b40e68824b1a201a6295695c8f7a46487dc14e5a320e5d5ac4ace2f909f4759b9e160
|
data/README.md
CHANGED
@@ -14,15 +14,16 @@ 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_number_is_too_short]
|
18
18
|
|
19
19
|
# Error codes
|
20
20
|
|
21
|
-
BankTools::GB::Errors::
|
22
|
-
BankTools::GB::Errors::
|
23
|
-
BankTools::GB::Errors::SORT_CODE_WITH_WRONG_LENGTH
|
24
|
-
BankTools::GB::Errors::
|
25
|
-
BankTools::GB::Errors::
|
21
|
+
BankTools::GB::Errors::ACCOUNT_NUMBER_IS_TOO_SHORT # => :account_number_is_too_short
|
22
|
+
BankTools::GB::Errors::ACCOUNT_NUMBER_IS_TOO_LONG # => :account_number_is_too_long
|
23
|
+
BankTools::GB::Errors::SORT_CODE_WITH_WRONG_LENGTH # => :sort_code_with_wrong_length
|
24
|
+
BankTools::GB::Errors::ACCOUNT_NUMBER_WITH_INVALID_CHARACTERS # => :account_number_with_invalid_characters
|
25
|
+
BankTools::GB::Errors::SORT_CODE_WITH_INVALID_CHARACTERS # => :sort_code_with_invalid_characters
|
26
|
+
BankTools::GB::Errors::ACCOUNT_NUMBER_DOES_NOT_MATCH_SORT_CODE # => :account_number_does_not_match_sort_code
|
26
27
|
|
27
28
|
## Installation
|
28
29
|
|
@@ -18,11 +18,11 @@ module BankTools
|
|
18
18
|
|
19
19
|
def errors
|
20
20
|
errors = []
|
21
|
-
errors << :
|
22
|
-
errors << :
|
21
|
+
errors << :account_number_is_too_short if account_number_is_too_short?
|
22
|
+
errors << :account_number_is_too_long if account_number_is_too_long?
|
23
23
|
errors << :sort_code_with_wrong_length if sort_code_with_wrong_length?
|
24
|
-
errors << :
|
25
|
-
errors << :
|
24
|
+
errors << :sort_code_with_invalid_characters if any_non_digits?(compact_sort_code)
|
25
|
+
errors << :account_number_with_invalid_characters if any_non_digits?(compact_account_number)
|
26
26
|
errors << :account_number_does_not_match_sort_code unless valid_account_number_with_sort_code?
|
27
27
|
errors
|
28
28
|
end
|
@@ -37,11 +37,11 @@ module BankTools
|
|
37
37
|
compact_sort_code.length != SORT_CODE_LENGTH
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
40
|
+
def account_number_is_too_short?
|
41
41
|
compact_account_number.length < ACCOUNT_NUMBER_MIN_LENGTH
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
44
|
+
def account_number_is_too_long?
|
45
45
|
compact_account_number.length > ACCOUNT_NUMBER_MAX_LENGTH
|
46
46
|
end
|
47
47
|
|
data/lib/banktools-gb/errors.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Banktools
|
2
2
|
module GB
|
3
3
|
module Errors
|
4
|
-
|
5
|
-
|
4
|
+
ACCOUNT_NUMBER_IS_TOO_SHORT = :account_number_is_too_short
|
5
|
+
ACCOUNT_NUMBER_IS_TOO_LONG = :account_number_is_too_long
|
6
6
|
SORT_CODE_WITH_WRONG_LENGTH = :sort_code_with_wrong_length
|
7
|
-
|
8
|
-
|
7
|
+
SORT_CODE_WITH_INVALID_CHARACTERS = :sort_code_with_invalid_characters
|
8
|
+
ACCOUNT_NUMBER_WITH_INVALID_CHARACTERS = :account_number_with_invalid_characters
|
9
9
|
ACCOUNT_NUMBER_DOES_NOT_MATCH_SORT_CODE = :account_number_does_not_match_sort_code
|
10
10
|
end
|
11
11
|
end
|
data/lib/banktools-gb/version.rb
CHANGED