FIX: less crazy error when post exceeds max length.

This commit is contained in:
Sam 2014-07-04 16:38:27 +10:00
parent c6ece058f0
commit 5b310c21b4
2 changed files with 3 additions and 1 deletions

View file

@ -36,6 +36,8 @@ en:
is_reserved: "is reserved"
errors:
messages:
too_long_validation: "is limited to %{max} characters; you entered %{length}."
embed:
load_from_remote: "There was an error loading that post."

View file

@ -5,7 +5,7 @@ class Validators::StrippedLengthValidator < ActiveModel::EachValidator
stripped_length = value.strip.length
record.errors.add attribute, (I18n.t('errors.messages.too_short', count: range.begin)) unless
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
else
record.errors.add attribute, (I18n.t('errors.messages.blank'))