Class: CarrierWaveDirect::Validations::ActiveModel::IsAttachedValidator

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



82
83
84
85
86
87
88
89
# File 'lib/carrierwave_direct/validations/active_model.rb', line 82

def validate_each(record, attribute, value)
  if value.blank? && !record.skip_is_attached_validations
    record.errors.add(
      attribute,
      :carrierwave_direct_attachment_missing
    )
  end
end