summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/custom_value.rb2
-rw-r--r--test/unit/custom_value_test.rb2
2 files changed, 3 insertions, 1 deletions
diff --git a/app/models/custom_value.rb b/app/models/custom_value.rb
index 6d4af178a..dae8f73ef 100644
--- a/app/models/custom_value.rb
+++ b/app/models/custom_value.rb
@@ -64,7 +64,7 @@ protected
when 'float'
begin; Kernel.Float(value); rescue; errors.add(:value, :invalid) end
when 'date'
- errors.add(:value, :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}$/ && begin; value.to_date; rescue; false end
when 'list'
errors.add(:value, :inclusion) unless custom_field.possible_values.include?(value)
end
diff --git a/test/unit/custom_value_test.rb b/test/unit/custom_value_test.rb
index c0778fb43..95931d277 100644
--- a/test/unit/custom_value_test.rb
+++ b/test/unit/custom_value_test.rb
@@ -64,6 +64,8 @@ class CustomValueTest < ActiveSupport::TestCase
assert v.valid?
v.value = 'abc'
assert !v.valid?
+ v.value = '1975-07-33'
+ assert !v.valid?
v.value = '1975-07-14'
assert v.valid?
end