* Move straightforward validations * Add color contrast validation to SiteConfig * Move domain and emoji validation to SiteConfig * Add specs * Update service object * Experimentally remove validation * Update spec * Fix comment
9 lines
317 B
Ruby
9 lines
317 B
Ruby
class EmojiOnlyValidator < ActiveModel::EachValidator
|
|
DEFAULT_MESSAGE = "contains non-emoji characters or invalid emoji".freeze
|
|
|
|
def validate_each(record, attribute, value)
|
|
return if value.gsub(EmojiRegex::RGIEmoji, "").blank?
|
|
|
|
record.errors.add(attribute, options[:message] || DEFAULT_MESSAGE)
|
|
end
|
|
end
|