From: Jean-Philippe Lang Date: Mon, 14 Jul 2014 15:50:41 +0000 (+0000) Subject: Handle min_length and max_length nil values (#17446). X-Git-Tag: 2.4.7~7 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fd8df67ddbe9219678caed5255ea47eadd60e061;p=redmine.git 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 --- 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