Class: ActiveModel::FormObject::Validators::NestedValidator

Inherits:
EachValidator
  • Object
show all
Defined in:
lib/active_model/form_object/validators/nested_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/active_model/form_object/validators/nested_validator.rb', line 5

def validate_each(record, attribute, value)

  if !value.nil? && record.send(attribute).invalid?
    record.send(attribute).errors.each do |k, v|
      record.errors[k] ||= []
      record.errors[k] << v
    end
  end
end