Module: Sequel::Plugins::ErrorSplitter::InstanceMethods

Defined in:
lib/sequel/plugins/error_splitter.rb

Instance Method Summary collapse

Instance Method Details

#_valid?Boolean

If the model instance is not valid, go through all of the errors entries. For any that apply to multiple columns, remove them and add separate error entries, one per column.

Returns:

  • (Boolean)


36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/sequel/plugins/error_splitter.rb', line 36

def _valid?(*)
  v = super
  unless v
    errors.keys.select{|k| k.is_a?(Array)}.each do |ks|
      msgs = errors.delete(ks)
      ks.each do |k|
        msgs.each do |msg|
          errors.add(k, msg)
        end
      end
    end
  end
  v
end