Class: Content::Validators::ContentValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
app/models/content/validators/content_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



4
5
6
7
8
9
10
# File 'app/models/content/validators/content_validator.rb', line 4

def validate_each(record, attribute, value)
  begin
    value.encode("UTF-8", 'binary') if !value.blank? && value.respond_to?(:encode)
  rescue
    record.errors[attribute] << (options[:message] || _("cannot be a binary file."))
  end
end