Class: ActiveStorageValidations::ProcessableImageValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ActiveStorageValidations::ProcessableImageValidator
- Includes:
- OptionProcUnfolding
- Defined in:
- lib/active_storage_validations/processable_image_validator.rb
Overview
:nodoc
Instance Method Summary collapse
Methods included from OptionProcUnfolding
Instance Method Details
#validate_each(record, attribute, _value) ⇒ Object
Rails 5
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/active_storage_validations/processable_image_validator.rb', line 24 def validate_each(record, attribute, _value) return true unless record.send(attribute).attached? changes = record.[attribute.to_s] return true if changes.blank? files = Array.wrap(changes.is_a?(ActiveStorage::Attached::Changes::CreateMany) ? changes.attachables : changes.attachable) files.each do |file| add_error(record, attribute, :image_not_processable) unless Metadata.new(file).valid? end end |