comparison app/models/custom_field.rb @ 1516:b450a9d58aed redmine-2.4

Update to Redmine SVN revision 13356 on 2.4-stable branch
author Chris Cannam
date Tue, 09 Sep 2014 09:28:31 +0100
parents e248c7af89ec
children dffacf8a6908
comparison
equal deleted inserted replaced
1494:e248c7af89ec 1516:b450a9d58aed
350 # Returns the error message for the given value regarding its format 350 # Returns the error message for the given value regarding its format
351 def validate_field_value_format(value) 351 def validate_field_value_format(value)
352 errs = [] 352 errs = []
353 unless value.to_s == '' 353 unless value.to_s == ''
354 errs << ::I18n.t('activerecord.errors.messages.invalid') unless regexp.blank? or value =~ Regexp.new(regexp) 354 errs << ::I18n.t('activerecord.errors.messages.invalid') unless regexp.blank? or value =~ Regexp.new(regexp)
355 errs << ::I18n.t('activerecord.errors.messages.too_short', :count => min_length) if min_length > 0 and value.length < min_length 355 errs << ::I18n.t('activerecord.errors.messages.too_short', :count => min_length) if min_length && min_length > 0 && value.length < min_length
356 errs << ::I18n.t('activerecord.errors.messages.too_long', :count => max_length) if max_length > 0 and value.length > max_length 356 errs << ::I18n.t('activerecord.errors.messages.too_long', :count => max_length) if max_length && max_length > 0 && value.length > max_length
357 357
358 # Format specific validations 358 # Format specific validations
359 case field_format 359 case field_format
360 when 'int' 360 when 'int'
361 errs << ::I18n.t('activerecord.errors.messages.not_a_number') unless value =~ /^[+-]?\d+$/ 361 errs << ::I18n.t('activerecord.errors.messages.not_a_number') unless value =~ /^[+-]?\d+$/