Class: Druid::Aggregation::FieldnameValidator

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

Constant Summary collapse

TYPES =
%w(count longSum doubleSum min max hyperUnique)

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/druid/aggregation.rb', line 13

def validate_each(record, attribute, value)
  if TYPES.include?(record.type)
    record.errors.add(attribute, 'may not be blank') if value.blank?
  else
    record.errors.add(attribute, "is not supported by type=#{record.type}") if value
  end
end