blob: 5491d3d5f4b71c901cf5672c3c67c2ba015945c0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
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
|