Sha256: a41464752bdf897d9f393d2524b12775b11203c39794ee38c96e703581fe791f

Contents?: true

Size: 381 Bytes

Versions: 2

Compression:

Stored size: 381 Bytes

Contents

class AttachmentContentTypeValidator < RailsUploads::Validators::Base
  
  def validate_each(record, attribute, value)
    if value.present? and not value.send(: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

2 entries across 2 versions & 1 rubygems

Version Path
rails_uploads-0.2.1 lib/rails_uploads/validators/attachment_content_type_validator.rb
rails_uploads-0.2.0 lib/rails_uploads/validators/attachment_content_type_validator.rb