Sha256: 79edbe904f200b0af7bd117de8ca29f70f7c97fcd0efcdd133d9ef44a43350ea

Contents?: true

Size: 709 Bytes

Versions: 9

Compression:

Stored size: 709 Bytes

Contents

# The Errors class is planned to replace AM::Errors. It provides proper nested error messages.
class Reform::Contract::Errors < ActiveModel::Errors
  def merge!(errors, prefix)
    errors.messages.each do |field, msgs|
      unless field.to_sym == :base
        field = (prefix+[field]).join(".").to_sym # TODO: why is that a symbol in Rails?
      end

      msgs.each do |msg|
        next if messages[field] and messages[field].include?(msg)
        add(field, msg)
      end # Forms now contains a plain errors hash. the errors for each item are still available in item.errors.
    end
  end

  def valid? # TODO: test me in unit test.
    empty?
  end

  def to_s
    messages.inspect
  end
end # Errors

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
reform-2.1.0.rc1 lib/reform/form/active_model/errors.rb
reform-2.0.5 lib/reform/form/active_model/errors.rb
reform-2.0.4 lib/reform/form/active_model/errors.rb
reform-2.0.3 lib/reform/form/active_model/errors.rb
reform-2.0.2 lib/reform/form/active_model/errors.rb
reform-2.0.1 lib/reform/form/active_model/errors.rb
reform-2.0.0 lib/reform/form/active_model/errors.rb
reform-2.0.0.rc3 lib/reform/contract/errors.rb
reform-2.0.0.rc2 lib/reform/contract/errors.rb