summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-07-11 14:13:59 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-07-11 14:13:59 +0000
commit308a922d80331d139b576d44728e1c49d5321a7f (patch)
tree3a5dd5475c6e00decd2f375677ce1967ab85b28c /app
parentdb1bfbd01801eb04472cc3baa9c19cc96a489303 (diff)
downloadredmine-308a922d80331d139b576d44728e1c49d5321a7f.tar.gz
redmine-308a922d80331d139b576d44728e1c49d5321a7f.zip
Validate date filters values.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6264 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/models/query.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/query.rb b/app/models/query.rb
index ac41ab478..ab0b3320d 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -176,6 +176,13 @@ class Query < ActiveRecord::Base
errors.add(label_for(field), :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^\d+$/) }
when :float
errors.add(label_for(field), :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^\d+(\.\d*)?$/) }
+ when :date, :date_past
+ case operator_for(field)
+ when "=", ">=", "<=", "><"
+ errors.add(label_for(field), :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^\d{4}-\d{2}-\d{2}$/) }
+ when ">t-", "<t-", "t-"
+ errors.add(label_for(field), :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^\d+$/) }
+ end
end
end