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

- (Object) validate_each(record, attribute, value)



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).spoofed?
    record.errors.add(attribute, :spoofed_media_type)
  end
end