Class: Dragonfly::Model::Validations::PropertyValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/dragonfly/model/validations.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(model, attribute, attachment) ⇒ Object


9
10
11
12
13
14
15
16
17
# File 'lib/dragonfly/model/validations.rb', line 9

def validate_each(model, attribute, attachment)
  if attachment
    property = attachment.send(property_name)
    model.errors.add(attribute, message(property, model)) unless matches?(property)
  end
rescue RuntimeError => e
  Dragonfly.warn("validation of property #{property_name} of #{attribute} failed with error #{e}")
  model.errors.add(attribute, message(nil, model))
end