summaryrefslogtreecommitdiffstats
path: root/func
diff options
context:
space:
mode:
authormakkalot <makkalot@gmail.com>2008-06-20 14:49:41 +0300
committermakkalot <makkalot@gmail.com>2008-06-20 14:49:41 +0300
commitc92df80d5e48cb56056bbe37c0982391cf376388 (patch)
treefb05edd6426d2f38957d87403106c549100ee89d /func
parenta947dfa3a910fbb8fe2b5dce9c7c150abd910790 (diff)
downloadthird_party-func-c92df80d5e48cb56056bbe37c0982391cf376388.tar.gz
third_party-func-c92df80d5e48cb56056bbe37c0982391cf376388.tar.xz
third_party-func-c92df80d5e48cb56056bbe37c0982391cf376388.zip
adding extra validation for range option in integers
Diffstat (limited to 'func')
-rw-r--r--func/minion/func_arg.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/func/minion/func_arg.py b/func/minion/func_arg.py
index 6ff7a35..6c416e4 100644
--- a/func/minion/func_arg.py
+++ b/func/minion/func_arg.py
@@ -74,7 +74,17 @@ class ArgCompatibility(object):
if arg_option!='options' and arg_option in self.__valid_args['string']:
raise IncompatibleTypesException('The options keyword should be used alone in a string cant be used with min_length,max_length,validator together')
- #will add here a new for integers
+ #if range keyword is used into a int argument the others shouldnt be there
+ if argument_dict.has_key('range'):
+ if len(argument_dict['range'])!=2:
+ raise IncompatibleTypesException('The range option should have 2 members [min,max]')
+ if not argument_dict['range'][0] < argument_dict['range'][1]:
+ raise IncompatibleTypesException('In the range option first member should be smaller than second [min,max]')
+ #check if another option was used there ...
+ for arg_option in argument_dict.keys():
+ if arg_option!='range' and arg_option in self.__valid_args['int']:
+ raise IncompatibleTypesException('The options range should be used alone into a int argument')
+
# we will use it everytime so not make lookups
the_type = argument_dict['type']