From 01c6d11253fa852d60b688d9c346553b8cb0aee7 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 20 Nov 2022 17:08:09 -0600 Subject: [PATCH] bans: validate ban duration is standard length. --- app/models/ban.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/ban.rb b/app/models/ban.rb index 6b952c41c..bc5747476 100644 --- a/app/models/ban.rb +++ b/app/models/ban.rb @@ -12,6 +12,8 @@ class Ban < ApplicationRecord belongs_to :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 validate :user, :validate_user_is_bannable, on: :create