Sha256: 8dbe7f6bd2757f44fb553cceedb5f541873181f703c74395233a63193b6f83bd
Contents?: true
Size: 790 Bytes
Versions: 2
Compression:
Stored size: 790 Bytes
Contents
module ACH module Validations def valid? reset_errors! is_a?(Component) ? valid_component? : valid_record? errors.empty? end def valid_component? counts = {} to_ach.each do |record| counts[record.class] ||= 0 unless record.valid? errors["#{record.class.name}##{counts[record.class] += 1}"] = record.errors end end end private :valid_component? def valid_record? self.class.fields.each do |field| errors[field] = "is required" unless fields[field] end end private :valid_record? def errors @errors || reset_errors! end def reset_errors! @errors = ActiveSupport::OrderedHash.new end private :reset_errors! end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ach_builder-0.0.2 | lib/ach/validations.rb |
ach_builder-0.0.1.1 | lib/ach/validations.rb |