0
0
Fork 0

Extract constants for column size length validation limits (#30045)

This commit is contained in:
Matt Jankowski 2024-04-24 04:56:28 -04:00 committed by GitHub
parent ebcf9840f4
commit f4a53f3fb4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 21 additions and 7 deletions

View file

@ -26,6 +26,8 @@ class Report < ApplicationRecord
include Paginable
include RateLimitable
COMMENT_SIZE_LIMIT = 1_000
rate_limit by: :account, family: :reports
belongs_to :account
@ -46,7 +48,7 @@ class Report < ApplicationRecord
# A report is considered local if the reporter is local
delegate :local?, to: :account
validates :comment, length: { maximum: 1_000 }, if: :local?
validates :comment, length: { maximum: COMMENT_SIZE_LIMIT }, if: :local?
validates :rule_ids, absence: true, if: -> { (category_changed? || rule_ids_changed?) && !violation? }
validate :validate_rule_ids, if: -> { (category_changed? || rule_ids_changed?) && violation? }