Class: Attachs::ActiveRecord::Validators::AttachmentContentTypeValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Attachs::ActiveRecord::Validators::AttachmentContentTypeValidator
- Defined in:
- lib/attachs/active_record/validators/attachment_content_type_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/attachs/active_record/validators/attachment_content_type_validator.rb', line 6 def validate_each(record, attribute, value) if value.exists? if .has_key? :with if [:with] !~ value.content_type record.errors.add attribute, :attachment_content_type_with end elsif .has_key? :in if [:in].exclude? value.content_type record.errors.add attribute, :attachment_content_type_in, types: [:in].to_sentence end end end end |