Sha256: c2c667c66dadecab54d7fe00cbd0c029c8ab43773735347cf083cd48a349049d

Contents?: true

Size: 374 Bytes

Versions: 4

Compression:

Stored size: 374 Bytes

Contents

class AttachmentContentTypeValidator < RailsUploads::Validators::Base
  
  def validate_each(record, attribute, value)
    if value.present? and not value.is_default?
      unless options[:in].include? value.extname.from(1)
        add_error record, attribute, 'errors.messages.attachment_content_type', types: options[:in].join(', ')
      end
    end
  end        
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_uploads-0.2.5 lib/rails_uploads/validators/attachment_content_type_validator.rb
rails_uploads-0.2.4 lib/rails_uploads/validators/attachment_content_type_validator.rb
rails_uploads-0.2.3 lib/rails_uploads/validators/attachment_content_type_validator.rb
rails_uploads-0.2.2 lib/rails_uploads/validators/attachment_content_type_validator.rb