Class: Elastictastic::Validations::NestedValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/elastictastic/validations.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



35
36
37
38
39
40
# File 'lib/elastictastic/validations.rb', line 35

def validate_each(record, attribute, value)
  value = [value].compact unless Array === value
  unless value.all? { |el| el.valid? }
    record.errors[:attribute] = :invalid
  end
end