Class: Druid::PostAggregation::ValueValidator

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

Constant Summary collapse

TYPES =
%w(constant)

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



77
78
79
80
81
82
83
# File 'lib/druid/post_aggregation.rb', line 77

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