You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
447 B
15 lines
447 B
8 years ago
|
class StatusLengthValidator < ActiveModel::Validator
|
||
|
def validate(status)
|
||
|
if status.local? && !status.reblog?
|
||
|
combinedText = status.text
|
||
|
if (status.spoiler? && status.spoiler_text.present?)
|
||
|
combinedText = status.spoiler_text + "\n" + status.text
|
||
|
end
|
||
|
|
||
|
maxChars = 500
|
||
|
unless combinedText.length <= maxChars
|
||
|
status.errors[:text] << "is too long (maximum is #{maxChars})"
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|