Class: Attachs::Extensions::ActiveRecord::Validations::AttachmentValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/attachs/extensions/active_record/validations/attachment_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, attachment_or_collection) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/attachs/extensions/active_record/validations/attachment_validator.rb', line 9

def validate_each(record, attribute, attachment_or_collection)
  case attachment_or_collection
  when Collection
    attachment_or_collection.each do |attachment|
      validate_one record, attribute, attachment
    end
  when Attachment
    validate_one record, attribute, attachment_or_collection
  end
end