diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-02-21 11:04:50 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-02-21 11:04:50 +0000 |
commit | fe28193e4eb9af2dc5262535a29ffde5249568fc (patch) | |
tree | bd4cf3a9fbada98e58e510ca0e25c42bf00676a7 /app/models/custom_value.rb | |
parent | 9a986ac0a51fe844eee816325e6a6d4122136d9a (diff) | |
download | redmine-fe28193e4eb9af2dc5262535a29ffde5249568fc.tar.gz redmine-fe28193e4eb9af2dc5262535a29ffde5249568fc.zip |
Merged Rails 2.2 branch. Redmine now requires Rails 2.2.2.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2493 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/custom_value.rb')
-rw-r--r-- | app/models/custom_value.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/app/models/custom_value.rb b/app/models/custom_value.rb index 1f662baa7..2d7d1cffe 100644 --- a/app/models/custom_value.rb +++ b/app/models/custom_value.rb @@ -45,22 +45,22 @@ class CustomValue < ActiveRecord::Base protected def validate if value.blank? - errors.add(:value, :activerecord_error_blank) if custom_field.is_required? and value.blank? + errors.add(:value, :blank) if custom_field.is_required? and value.blank? else - errors.add(:value, :activerecord_error_invalid) unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp) - errors.add(:value, :activerecord_error_too_short) if custom_field.min_length > 0 and value.length < custom_field.min_length - errors.add(:value, :activerecord_error_too_long) if custom_field.max_length > 0 and value.length > custom_field.max_length + errors.add(:value, :invalid) unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp) + errors.add(:value, :too_short) if custom_field.min_length > 0 and value.length < custom_field.min_length + errors.add(:value, :too_long) if custom_field.max_length > 0 and value.length > custom_field.max_length # Format specific validations case custom_field.field_format when 'int' - errors.add(:value, :activerecord_error_not_a_number) unless value =~ /^[+-]?\d+$/ + errors.add(:value, :not_a_number) unless value =~ /^[+-]?\d+$/ when 'float' - begin; Kernel.Float(value); rescue; errors.add(:value, :activerecord_error_invalid) end + begin; Kernel.Float(value); rescue; errors.add(:value, :invalid) end when 'date' - errors.add(:value, :activerecord_error_not_a_date) unless value =~ /^\d{4}-\d{2}-\d{2}$/ + errors.add(:value, :not_a_date) unless value =~ /^\d{4}-\d{2}-\d{2}$/ when 'list' - errors.add(:value, :activerecord_error_inclusion) unless custom_field.possible_values.include?(value) + errors.add(:value, :inclusion) unless custom_field.possible_values.include?(value) end end end |