From d42782b31868687fbf7e1caec8fe3dbbdb9bd493 Mon Sep 17 00:00:00 2001 From: Jeremy Banks Date: Mon, 18 Feb 2013 21:57:46 -0500 Subject: [PATCH] Using LengthValidator's localized messages for StrippedLengthValidator. --- app/models/stripped_length_validator.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/stripped_length_validator.rb b/app/models/stripped_length_validator.rb index 2342eab71c7..b84ff0b0090 100644 --- a/app/models/stripped_length_validator.rb +++ b/app/models/stripped_length_validator.rb @@ -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