mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 12:23:36 +08:00
12 lines
348 B
Ruby
12 lines
348 B
Ruby
class MaxEmojisValidator < ActiveModel::EachValidator
|
|
|
|
def validate_each(record, attribute, value)
|
|
if Emoji.unicode_unescape(value).scan(/:([\w\-+]+(?::t\d)?):/).size > SiteSetting.max_emojis_in_title
|
|
record.errors.add(
|
|
attribute, :max_emojis,
|
|
max_emojis_count: SiteSetting.max_emojis_in_title
|
|
)
|
|
end
|
|
end
|
|
end
|