Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…ams if a param value was supplied
  • Loading branch information...
commit 8f8cc319480903bf29276857d5ad1add5232b4fc 1 parent 00d46a2
James Bunch authored October 27, 2011

Showing 1 changed file with 6 additions and 1 deletion. Show diff stats Hide diff stats

  1. 7  lib/params_verification.rb
7  lib/params_verification.rb
@@ -235,7 +235,12 @@ def self.run_optional_rule(rule, params, namespace=nil)
235 235
     if choices && param_value && !choices.include?(param_value)
236 236
       raise InvalidParamValue, "Value for parameter '#{param_name}' (#{param_value}) is not in the allowed set of values."
237 237
     end
238  
-    
  238
+
  239
+    if rule.options[:minvalue] && param_value
  240
+      min = rule.options[:minvalue]
  241
+      raise InvalidParamValue, "Value for parameter '#{param_name}' is lower than the min accepted value (#{min})." if param_value.to_i < min
  242
+    end
  243
+
239 244
     params
240 245
   end
241 246
   

0 notes on commit 8f8cc31

Please sign in to comment.
Something went wrong with that request. Please try again.