From fd8df67ddbe9219678caed5255ea47eadd60e061 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 14 Jul 2014 15:50:41 +0000 Subject: Handle min_length and max_length nil values (#17446). git-svn-id: http://svn.redmine.org/redmine/branches/2.4-stable@13328 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/custom_field.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index 00f1831d5..dd7597596 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -352,8 +352,8 @@ class CustomField < ActiveRecord::Base errs = [] unless value.to_s == '' errs << ::I18n.t('activerecord.errors.messages.invalid') unless regexp.blank? or value =~ Regexp.new(regexp) - errs << ::I18n.t('activerecord.errors.messages.too_short', :count => min_length) if min_length > 0 and value.length < min_length - errs << ::I18n.t('activerecord.errors.messages.too_long', :count => max_length) if max_length > 0 and value.length > max_length + errs << ::I18n.t('activerecord.errors.messages.too_short', :count => min_length) if min_length && min_length > 0 && value.length < min_length + errs << ::I18n.t('activerecord.errors.messages.too_long', :count => max_length) if max_length && max_length > 0 && value.length > max_length # Format specific validations case field_format -- cgit v1.2.3