Class: Paperclip::Validators::MediaTypeSpoofDetectionValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/paperclip/validators/media_type_spoof_detection_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



6
7
8
9
10
11
# File 'lib/paperclip/validators/media_type_spoof_detection_validator.rb', line 6

def validate_each(record, attribute, value)
  adapter = Paperclip.io_adapters.for(value)
  if Paperclip::MediaTypeSpoofDetector.using(adapter, value.original_filename, value.content_type).spoofed?
    record.errors.add(attribute, :spoofed_media_type)
  end
end