Use `length` validation instead of `presence` for `MuteRule`

This commit is contained in:
Andreas Nedbal 2023-10-15 06:40:32 +02:00 committed by Andreas Nedbal
parent d40519dffa
commit f3f8e99045
1 changed files with 1 additions and 1 deletions

View File

@ -3,7 +3,7 @@
class MuteRule < ApplicationRecord
belongs_to :user
validates :muted_phrase, presence: true
validates :muted_phrase, length: { minimum: 1 }
def applies_to?(post)
!!(post.content =~ /\b#{Regexp.escape(muted_phrase)}\b/i)