This commit is contained in:
Zee Aslam 2025-09-05 09:07:27 +00:00 committed by GitHub
commit 4ed3c891ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -109,3 +109,9 @@ FETCH_REPLIES_MAX_SINGLE=500
# Max number of replies Collection pages to fetch - total
FETCH_REPLIES_MAX_PAGES=500
# Maximum allowed poll options
MAX_POLL_OPTIONS=4
# Maximum allowed poll option characters
MAX_POLL_OPTION_CHARS=50

View File

@ -1,8 +1,8 @@
# frozen_string_literal: true
class PollOptionsValidator < ActiveModel::Validator
MAX_OPTIONS = 4
MAX_OPTION_CHARS = 50
MAX_OPTIONS = (ENV['MAX_POLL_OPTIONS'] || 4).to_i
MAX_OPTION_CHARS = (ENV['MAX_POLL_OPTION_CHARS'] || 50).to_i
def validate(poll)
poll.errors.add(:options, I18n.t('polls.errors.too_few_options')) unless poll.options.size > 1