Class: Druid::Filter::FieldsValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Druid::Filter::FieldsValidator
- Defined in:
- lib/druid/filter.rb
Constant Summary collapse
- TYPES =
%w(and or)
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/druid/filter.rb', line 52 def validate_each(record, attribute, value) if TYPES.include?(record.type) value.each(&:valid?) # trigger validation value.each do |fvalue| fvalue.errors..each do |k, v| record.errors.add(attribute, { k => v }) end end else record.errors.add(attribute, "is not supported by type=#{record.type}") unless value.blank? end end |