Sha256: a6e96e288554cf49d55b4a7594469569d23f152416814c53af0cb42aa4ba4500
Contents?: true
Size: 670 Bytes
Versions: 3
Compression:
Stored size: 670 Bytes
Contents
require "banktools-at/errors" module BankTools module AT class BLZ extend AttrExtras.mixin LENGTH = 5 pattr_initialize :original_value def valid? errors.none? end def errors errors = [] errors << Errors::TOO_SHORT if compacted_value.length < LENGTH errors << Errors::TOO_LONG if compacted_value.length > LENGTH errors << Errors::INVALID_CHARACTERS if any_non_digits? errors end private def any_non_digits? compacted_value.match(/\D/) end def compacted_value original_value.to_s.gsub(/[\s-]/, "") end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
banktools-at-0.2.1 | lib/banktools-at/blz.rb |
banktools-at-0.2.0 | lib/banktools-at/blz.rb |
banktools-at-0.1.0 | lib/banktools-at/blz.rb |