discourse/lib/validators/topic_title_length_validator.rb

13 lines
638 B
Ruby
Raw Normal View History

class TopicTitleLengthValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if record.private_message?
2013-06-28 20:49:47 -05:00
private_message_title_validator = ActiveModel::Validations::LengthValidator.new({attributes: :title, in: SiteSetting.private_message_title_length, allow_blank: true})
private_message_title_validator.validate_each(record, attribute, value)
else
2013-06-28 20:49:47 -05:00
topic_title_validator = ActiveModel::Validations::LengthValidator.new({attributes: :title, in: SiteSetting.topic_title_length, allow_blank: true})
topic_title_validator.validate_each(record, attribute, value)
end
end
end