Class: CarrierWaveDirect::Validations::ActiveModel::IsUploadedValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/carrierwave_direct/validations/active_model.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/carrierwave_direct/validations/active_model.rb', line 53

def validate_each(record, attribute, value)
  if record.new_record?
    unless (record.send("has_#{attribute}_upload?") || record.send("has_remote_#{attribute}_net_url?"))
      record.errors.add(
        attribute,
        :carrierwave_direct_upload_missing
      )
      record.errors.add(
        :"remote_#{attribute}_net_url",
        :blank
      )
    end
  end
end