bans: validate ban duration is standard length.
This commit is contained in:
@@ -12,6 +12,8 @@ class Ban < ApplicationRecord
|
|||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :banner, :class_name => "User"
|
belongs_to :banner, :class_name => "User"
|
||||||
|
|
||||||
|
validates :duration, presence: true
|
||||||
|
validates :duration, inclusion: { in: [1.day, 3.days, 1.week, 1.month, 3.months, 6.months, 1.year, 100.years], message: "%{value} is not a valid ban duration" }, if: :duration_changed?
|
||||||
validates :reason, presence: true
|
validates :reason, presence: true
|
||||||
validate :user, :validate_user_is_bannable, on: :create
|
validate :user, :validate_user_is_bannable, on: :create
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user