Class: Druid::Filter::FunctionValidator

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

Constant Summary collapse

TYPES =
%w(javascript)

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



114
115
116
117
118
119
120
# File 'lib/druid/filter.rb', line 114

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