class Druid::Query::GranularityValidator
Constants
- SIMPLE
- TYPES
Public Instance Methods
validate_each(record, attribute, value)
click to toggle source
# File lib/druid/query.rb, line 49 def validate_each(record, attribute, value) if TYPES.include?(record.queryType) if value.is_a?(String) record.errors.add(attribute, "must be one of #{SIMPLE.inspect}") unless SIMPLE.include?(value) elsif value.is_a?(Granularity) value.valid? # trigger validation value.errors.messages.each do |k, v| record.errors.add(attribute, { k => v }) end else record.errors.add(attribute, "invalid type or class: #{value.inspect}") end else record.errors.add(attribute, "is not supported by type=#{record.queryType}") if value end end