summaryrefslogtreecommitdiffstats
path: root/app/models/custom_value.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/custom_value.rb')
-rw-r--r--app/models/custom_value.rb16
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