Class: BankTools::DE::Account
- Inherits:
-
Object
- Object
- BankTools::DE::Account
- Defined in:
- lib/banktools-de/account.rb
Constant Summary collapse
- 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
2
- MAX_LENGTH =
15
- GROUPS_OF =
3
Instance Method Summary collapse
Instance Method Details
#errors ⇒ Object
34 35 36 37 38 39 40 |
# 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 ⇒ Object
22 23 24 25 26 27 28 |
# 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? ⇒ Boolean
30 31 32 |
# File 'lib/banktools-de/account.rb', line 30 def valid? errors.empty? end |