class BankTools::GB::Account
Constants
- LENGTH
Officially, bank accounts in the UK can be between 6 and 10 digits, but the standard is 8, and any system that receives them will require them to be zero-padded. Customers should be used to prepend zeroes, and it should not be an issue. If this becomes an issue, lets consider handling auto-zeropadding, but it is both less technical issues and easier to give feedback to the user if we enforce the 8 digit length rule.
Public Instance Methods
compacted_value()
click to toggle source
# File lib/banktools-gb/account.rb, line 32 def compacted_value original_value.to_s.gsub(/[\s-]/, "") end
errors()
click to toggle source
# File lib/banktools-gb/account.rb, line 22 def errors errors = [] errors << Errors::ACCOUNT_TOO_SHORT if compacted_value.length < LENGTH errors << Errors::ACCOUNT_TOO_LONG if compacted_value.length > LENGTH errors << Errors::ACCOUNT_INVALID_CHARACTERS if any_non_digits? errors end
valid?()
click to toggle source
# File lib/banktools-gb/account.rb, line 18 def valid? errors.none? end
Private Instance Methods
any_non_digits?()
click to toggle source
# File lib/banktools-gb/account.rb, line 38 def any_non_digits? compacted_value.match(/\D/) end