class BankTools::DE::Account

Constants

GROUPS_OF
MAX_LENGTH
MIN_LENGTH

Picked some reasonable values, erring on the side of allowing too much. Seems to claim max 10: docs.oracle.com/cd/E18727_01/doc.121/e13483/T359831T498954.htm Seems to claim 2 - 13: www.credit-card.be/BankAccount/ValidationRules.htm#DE_Validation

Public Instance Methods

errors() click to toggle source
# File lib/banktools-de/account.rb, line 34
def errors
  errors = []
  errors << Errors::TOO_SHORT if compacted_value.length < MIN_LENGTH
  errors << Errors::TOO_LONG if compacted_value.length > MAX_LENGTH
  errors << Errors::INVALID_CHARACTERS if compacted_value.match(/\D/)
  errors
end
normalize() click to toggle source
# File lib/banktools-de/account.rb, line 22
def normalize
  if valid?
    compacted_value.scan(/\d{#{GROUPS_OF}}|\d+/).join(" ")
  else
    original_value
  end
end
valid?() click to toggle source
# File lib/banktools-de/account.rb, line 30
def valid?
  errors.empty?
end

Private Instance Methods

compacted_value() click to toggle source
# File lib/banktools-de/account.rb, line 44
def compacted_value
  original_value.to_s.gsub(/[\s-]/, "")
end