Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix poll validation issues #10186

Merged
merged 1 commit into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/validators/poll_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def validate(poll)
poll.errors.add(:options, I18n.t('polls.errors.too_many_options', max: MAX_OPTIONS)) if poll.options.size > MAX_OPTIONS
poll.errors.add(:options, I18n.t('polls.errors.over_character_limit', max: MAX_OPTION_CHARS)) if poll.options.any? { |option| option.mb_chars.grapheme_length > MAX_OPTION_CHARS }
poll.errors.add(:options, I18n.t('polls.errors.duplicate_options')) unless poll.options.uniq.size == poll.options.size
poll.errors.add(:expires_at, I18n.t('polls.errors.duration_too_long')) if poll.expires_at.nil? || poll.expires_at - current_time >= MAX_EXPIRATION
poll.errors.add(:expires_at, I18n.t('polls.errors.duration_too_short')) if poll.expires_at.present? && poll.expires_at - current_time <= MIN_EXPIRATION
poll.errors.add(:expires_at, I18n.t('polls.errors.duration_too_long')) if poll.expires_at.nil? || poll.expires_at - current_time > MAX_EXPIRATION
poll.errors.add(:expires_at, I18n.t('polls.errors.duration_too_short')) if poll.expires_at.present? && poll.expires_at - current_time < MIN_EXPIRATION
end
end
4 changes: 2 additions & 2 deletions config/locales/co.yml
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,9 @@ co:
duration_too_long: hè troppu luntanu indè u futuru
duration_too_short: hè troppu prossimu
expired: U scandagliu hè digià finitu
over_character_limit: ùn ponu micca esse più longhi chè %{MAX} caratteri
over_character_limit: ùn ponu micca esse più longhi chè %{max} caratteri
too_few_options: deve avè più d'un'uzzione
too_many_options: ùn pò micca avè più di %{MAX} uzzione
too_many_options: ùn pò micca avè più di %{max} uzzione
preferences:
languages: Lingue
other: Altre
Expand Down
4 changes: 2 additions & 2 deletions config/locales/cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,9 @@ cs:
duration_too_long: je příliš daleko v budoucnosti
duration_too_short: je příliš brzy
expired: Anketa již skončila
over_character_limit: nesmí být každá delší než %{MAX} znaků
over_character_limit: nesmí být každá delší než %{max} znaků
too_few_options: musí mít více než jednu položku
too_many_options: nesmí obsahovat více než %{MAX} položky
too_many_options: nesmí obsahovat více než %{max} položky
preferences:
languages: Jazyky
other: Ostatní
Expand Down
4 changes: 2 additions & 2 deletions config/locales/el.yml
Original file line number Diff line number Diff line change
Expand Up @@ -740,9 +740,9 @@ el:
duration_too_long: είναι πολύ μακριά στο μέλλον
duration_too_short: είναι πολύ σύντομα
expired: Η ψηφοφορία έχει ήδη λήξει
over_character_limit: δε μπορεί να υπερβαίνει τους %{MAX} χαρακτήρες έκαστη
over_character_limit: δε μπορεί να υπερβαίνει τους %{max} χαρακτήρες έκαστη
too_few_options: πρέπει να έχει περισσότερες από μια επιλογές
too_many_options: δεν μπορεί να έχει περισσότερες από %{MAX} επιλογές
too_many_options: δεν μπορεί να έχει περισσότερες από %{max} επιλογές
preferences:
languages: Γλώσσες
other: Άλλο
Expand Down
4 changes: 2 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,9 @@ en:
duration_too_long: is too far into the future
duration_too_short: is too soon
expired: The poll has already ended
over_character_limit: cannot be longer than %{MAX} characters each
over_character_limit: cannot be longer than %{max} characters each
too_few_options: must have more than one item
too_many_options: can't contain more than %{MAX} items
too_many_options: can't contain more than %{max} items
preferences:
languages: Languages
other: Other
Expand Down
4 changes: 2 additions & 2 deletions config/locales/fa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,9 @@ fa:
duration_too_long: در آیندهٔ خیلی دور است
duration_too_short: در آیندهٔ خیلی نزدیک است
expired: این نظرسنجی به پایان رسیده است
over_character_limit: هر کدام نمی‌تواند از %{MAX} نویسه طولانی‌تر باشد
over_character_limit: هر کدام نمی‌تواند از %{max} نویسه طولانی‌تر باشد
too_few_options: حتماً باید بیش از یک گزینه داشته باشد
too_many_options: نمی‌تواند بیشتر از %{MAX} گزینه داشته باشد
too_many_options: نمی‌تواند بیشتر از %{max} گزینه داشته باشد
preferences:
languages: تنظیمات زبان
other: سایر تنظیمات
Expand Down
4 changes: 2 additions & 2 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,9 @@ fr:
duration_too_long: est trop loin dans le futur
duration_too_short: est trop tôt
expired: Ce sondage est déjà terminé
over_character_limit: ne peuvent être plus long que %{MAX} caractères chacun
over_character_limit: ne peuvent être plus long que %{max} caractères chacun
too_few_options: doit avoir plus qu'une proposition
too_many_options: ne peut contenir plus que %{MAX} propositions
too_many_options: ne peut contenir plus que %{max} propositions
preferences:
languages: Langues
other: Autre
Expand Down
4 changes: 2 additions & 2 deletions config/locales/gl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,9 @@ gl:
duration_too_long: está moi lonxe no futuro
duration_too_short: é demasiado cedo
expired: A sondaxe rematou
over_character_limit: non poden ter máis de %{MAX} caracteres cada unha
over_character_limit: non poden ter máis de %{max} caracteres cada unha
too_few_options: debe ter máis de unha opción
too_many_options: non pode haber máis de %{MAX} opcións
too_many_options: non pode haber máis de %{max} opcións
preferences:
languages: Idiomas
other: Outro
Expand Down
4 changes: 2 additions & 2 deletions config/locales/ko.yml
Original file line number Diff line number Diff line change
Expand Up @@ -743,9 +743,9 @@ ko:
duration_too_long: 너무 먼 미래입니다
duration_too_short: 너무 가깝습니다
expired: 투표가 이미 끝났습니다
over_character_limit: 각각 %{MAX} 글자를 넘을 수 없습니다
over_character_limit: 각각 %{max} 글자를 넘을 수 없습니다
too_few_options: 한가지 이상의 항목을 포함해야 합니다
too_many_options: 항목은 %{MAX}개를 넘을 수 없습니다
too_many_options: 항목은 %{max}개를 넘을 수 없습니다
preferences:
languages: 언어
other: 기타
Expand Down
4 changes: 2 additions & 2 deletions config/locales/sk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,9 @@ sk:
duration_too_long: je príliš ďaleko do budúcnosti
duration_too_short: je príliš skoro
expired: Anketa už skončila
over_character_limit: každá nemôže byť dlhšia ako %{MAX} znakov
over_character_limit: každá nemôže byť dlhšia ako %{max} znakov
too_few_options: musí mať viac ako jednu položku
too_many_options: nemôže zahŕňať viac ako %{MAX} položiek
too_many_options: nemôže zahŕňať viac ako %{max} položiek
preferences:
languages: Jazyky
other: Ostatné
Expand Down