Class: Content::Validators::DescriptionFormat

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

Constant Summary collapse

MAX_LENGTH =
1000

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



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

def validate_each(record, attribute, value)
  if value
    record.errors[attribute] << N_("cannot contain more than %s characters") % MAX_LENGTH unless value.length <= MAX_LENGTH
  end
end