Sha256: f3eaeac3368d79f9c4da6d910922cd04c57d1d932aa49d2b60745ad2fc4be439
Contents?: true
Size: 1002 Bytes
Versions: 14
Compression:
Stored size: 1002 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
14 entries across 14 versions & 1 rubygems