class Druid::Filter::FieldValidator

Constants

TYPES

Public Instance Methods

validate_each(record, attribute, value) click to toggle source
# File lib/druid/filter.rb, line 85
def validate_each(record, attribute, value)
  if TYPES.include?(record.type)
    if value
      value.valid? # trigger validation
      value.errors.messages.each do |k, v|
        record.errors.add(attribute, { k => v })
      end
    else
      record.errors.add(attribute, "may not be blank")
    end
  else
    record.errors.add(attribute, "is not supported by type=#{record.type}") if value
  end
end