Class: Druid::PostAggregation::FieldsValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/druid/post_aggregation.rb

Constant Summary collapse

TYPES =
%w(arithmetic)

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/druid/post_aggregation.rb', line 38

def validate_each(record, attribute, value)
  if TYPES.include?(record.type)
    value.each(&:valid?) # trigger validation
    value.each do |fvalue|
      fvalue.errors.messages.each do |k, v|
        record.errors.add(attribute, { k => v })
      end
    end
  else
    record.errors.add(attribute, "is not supported by type=#{record.type}") if value
  end
end