Permalink
Browse files

param verification: enforce a 'minvalue' restriction for optional par…

…ams if a param value was supplied
  • Loading branch information...
1 parent 00d46a2 commit 8f8cc319480903bf29276857d5ad1add5232b4fc @fallwith fallwith committed Oct 27, 2011
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/params_verification.rb
View
7 lib/params_verification.rb
@@ -235,7 +235,12 @@ def self.run_optional_rule(rule, params, namespace=nil)
if choices && param_value && !choices.include?(param_value)
raise InvalidParamValue, "Value for parameter '#{param_name}' (#{param_value}) is not in the allowed set of values."
end
-
+
+ if rule.options[:minvalue] && param_value
+ min = rule.options[:minvalue]
+ raise InvalidParamValue, "Value for parameter '#{param_name}' is lower than the min accepted value (#{min})." if param_value.to_i < min
+ end
+
params
end

0 comments on commit 8f8cc31

Please sign in to comment.