Sha256: e85e094a90d322cf7406a212001fff3f38506f9ee40a44214e604d5b8487ad04
Contents?: true
Size: 1003 Bytes
Versions: 35
Compression:
Stored size: 1003 Bytes
Contents
require 'active_model/validations/presence' module Paperclip module Validators class AttachmentFileTypeIgnoranceValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) # This doesn't do anything. It's just to mark that you don't care about # the file_names or content_types of your incoming attachments. end def self.helper_method_name :do_not_validate_attachment_file_type end end module HelperMethods # Places ActiveModel validations on the presence of a file. # Options: # * +if+: A lambda or name of an instance method. Validation will only # be run if this lambda or method returns true. # * +unless+: Same as +if+ but validates if lambda or method returns false. def do_not_validate_attachment_file_type(*attr_names) options = _merge_attributes(attr_names) validates_with AttachmentFileTypeIgnoranceValidator, options.dup end end end end
Version data entries
35 entries across 33 versions & 6 rubygems