Class: BankTools::GB::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/banktools-gb/account.rb

Constant Summary collapse

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.

8

Instance Method Summary collapse

Instance Method Details

#compacted_valueObject



32
33
34
# File 'lib/banktools-gb/account.rb', line 32

def compacted_value
  original_value.to_s.gsub(/[\s-]/, "")
end

#errorsObject



22
23
24
25
26
27
28
29
30
# File 'lib/banktools-gb/account.rb', line 22

def errors
  errors = []

  errors << Errors:: if compacted_value.length < LENGTH
  errors << Errors:: if compacted_value.length > LENGTH
  errors << Errors:: if any_non_digits?

  errors
end

#valid?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/banktools-gb/account.rb', line 18

def valid?
  errors.none?
end