Sha256: 1b4b263122a48049c279d8daa3592e79eb321c82c449ca031195770f7e9e0e89
Contents?: true
Size: 663 Bytes
Versions: 3
Compression:
Stored size: 663 Bytes
Contents
module DataMapper class ValidationErrors def initialize @errors = Hash.new { |h,k| h[k.to_sym] = [] } end # Clear existing validation errors. def clear! @errors.clear end # Add a validation error. Use the attribute :general if # the error doesn't apply to a specific attribute. def add(attribute, message) @errors[attribute] << message end # Collect all errors into a single list. def full_messages @errors.inject([]) do |list,pair| list += pair.last end end # Are any errors present? def empty? @errors.empty? end end end
Version data entries
3 entries across 3 versions & 1 rubygems