Class: Druid::Having::HavingValidator

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

Constant Summary collapse

TYPES =
%w(not)

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/druid/having.rb', line 33

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