Sha256: 17f50a58a0c17b952ffaa32366ec95818fd2a2f228c8123a785acfedc57744c6
Contents?: true
Size: 739 Bytes
Versions: 3
Compression:
Stored size: 739 Bytes
Contents
require "attr_extras/explicit" require "banktools-at/errors" module BankTools module AT class Account extend AttrExtras.mixin MIN_LENGTH = 4 MAX_LENGTH = 11 pattr_initialize :original_value def valid? errors.none? end 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 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/account.rb |
banktools-at-0.2.0 | lib/banktools-at/account.rb |
banktools-at-0.1.0 | lib/banktools-at/account.rb |