Sha256: 9f787cf651d768ad5db5fe3d20958c1f6eb3079909e85069d07af26d814beb47

Contents?: true

Size: 455 Bytes

Versions: 1

Compression:

Stored size: 455 Bytes

Contents

class AttachmentContentTypeValidator < RailsUploads::Validators::Base
  
  # validates :attr, :attachment_content_type => { :in => ['png', 'gif'] }
  
  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

1 entries across 1 versions & 1 rubygems

Version Path
rails_uploads-0.1.5 lib/rails_uploads/validators/attachment_content_type_validator.rb