class Druid::Query::AggregationsValidator

Constants

TYPES

Public Instance Methods

validate_each(record, attribute, value) click to toggle source
# File lib/druid/query.rb, line 121
def validate_each(record, attribute, value)
  if TYPES.include?(record.queryType)
    if !value.is_a?(Array) || value.blank?
      record.errors.add(attribute, 'must be a list with at least one aggregator')
    else
      value.each(&:valid?) # trigger validation
      value.each do |avalue|
        avalue.errors.messages.each do |k, v|
          record.errors.add(attribute, { k => v })
        end
      end
    end
  else
    record.errors.add(attribute, "is not supported by type=#{record.queryType}") if value
  end
end