mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 03:32:45 +08:00
FIX: less crazy error when post exceeds max length.
This commit is contained in:
parent
c6ece058f0
commit
5b310c21b4
|
@ -36,6 +36,8 @@ en:
|
||||||
is_reserved: "is reserved"
|
is_reserved: "is reserved"
|
||||||
|
|
||||||
errors:
|
errors:
|
||||||
|
messages:
|
||||||
|
too_long_validation: "is limited to %{max} characters; you entered %{length}."
|
||||||
embed:
|
embed:
|
||||||
load_from_remote: "There was an error loading that post."
|
load_from_remote: "There was an error loading that post."
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ class Validators::StrippedLengthValidator < ActiveModel::EachValidator
|
||||||
stripped_length = value.strip.length
|
stripped_length = value.strip.length
|
||||||
record.errors.add attribute, (I18n.t('errors.messages.too_short', count: range.begin)) unless
|
record.errors.add attribute, (I18n.t('errors.messages.too_short', count: range.begin)) unless
|
||||||
stripped_length >= range.begin
|
stripped_length >= range.begin
|
||||||
record.errors.add attribute, (I18n.t('errors.messages.too_long', count: range.end)) unless
|
record.errors.add attribute, (I18n.t('errors.messages.too_long_validation', max: range.end, length: stripped_length)) unless
|
||||||
stripped_length <= range.end
|
stripped_length <= range.end
|
||||||
else
|
else
|
||||||
record.errors.add attribute, (I18n.t('errors.messages.blank'))
|
record.errors.add attribute, (I18n.t('errors.messages.blank'))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user