2013-06-04 16:58:25 -05:00
|
|
|
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)
|
2013-06-04 16:58:25 -05:00
|
|
|
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)
|
2013-06-04 16:58:25 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|