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.

10 lines
464 B

# frozen_string_literal: true
class DisallowedHashtagsValidator < ActiveModel::Validator
def validate(status)
return unless status.local? && !status.reblog?
disallowed_hashtags = Tag.matching_name(Extractor.extract_hashtags(status.text)).reject(&:usable?)
status.errors.add(:text, I18n.t('statuses.disallowed_hashtags', tags:', '), count: disallowed_hashtags.size)) unless disallowed_hashtags.empty?