2013-06-04 17:58:25 -04:00
|
|
|
class TopicTitleLengthValidator < ActiveModel::EachValidator
|
|
|
|
|
|
|
|
|
|
def validate_each(record, attribute, value)
|
|
|
|
|
if record.private_message?
|
2013-06-29 03:49:47 +02: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)
|
2013-06-04 17:58:25 -04:00
|
|
|
else
|
2013-06-29 03:49:47 +02: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)
|
2013-06-04 17:58:25 -04:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|