mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
Using LengthValidator's localized messages for StrippedLengthValidator.
This commit is contained in:
parent
eb2a5e4654
commit
d42782b318
1 changed files with 3 additions and 3 deletions
|
@ -3,12 +3,12 @@ class StrippedLengthValidator < ActiveModel::EachValidator
|
|||
unless value.nil?
|
||||
stripped_length = value.strip.length
|
||||
range = options[:in]
|
||||
record.errors.add attribute, (options[:message] || "is too short (minimum is #{range.begin}).") unless
|
||||
record.errors.add attribute, (options[:message] || I18n.t('errors.messages.too_short', count: range.begin)) unless
|
||||
stripped_length >= range.begin
|
||||
record.errors.add attribute, (options[:message] || "is too long (maximum is #{range.end}).") unless
|
||||
record.errors.add attribute, (options[:message] || I18n.t('errors.messages.too_long', count: range.end)) unless
|
||||
stripped_length <= range.end
|
||||
else
|
||||
record.errors.add attribute, (options[:message] || "is required.")
|
||||
record.errors.add attribute, (options[:message] || I18n.t('errors.messages.blank'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue