Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Clean up AttachmentContentTypeValidator conditions
  • Loading branch information
sikachu committed Mar 27, 2012
1 parent bd528ba commit 36d1289
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/paperclip/validators/attachment_content_type_validator.rb
Expand Up @@ -6,12 +6,10 @@ def validate_each(record, attribute, value)
value = record.send(:read_attribute_for_validation, attribute)
allowed_types = [options[:content_type]].flatten

if value.present?
unless allowed_types.any? { |type| type === value }
record.errors.add(attribute, :invalid, options.merge(
:types => allowed_types.join(', ')
))
end
if value.present? && allowed_types.none? { |type| type === value }
record.errors.add(attribute, :invalid, options.merge(
:types => allowed_types.join(', ')
))
end
end

Expand Down

0 comments on commit 36d1289

Please sign in to comment.