File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
flask_parameter_validation Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ def nested_func(**kwargs):
66
66
else :
67
67
return error_response
68
68
69
- # If typing's Any, ClassVar or Optional , don't validate type
69
+ # If typing's Any or ClassVar , don't validate type
70
70
if isinstance (param_annotation , typing ._SpecialForm ):
71
71
valid = True
72
72
allowed_types = ["all" ]
@@ -80,6 +80,27 @@ def nested_func(**kwargs):
80
80
else :
81
81
allowed_types = (param_annotation ,)
82
82
83
+ # If query parameter, try converting to match
84
+ if param_type .__class__ == Query :
85
+ # int conversion
86
+ if param_annotation == int :
87
+ try :
88
+ user_input = int (user_input )
89
+ except ValueError :
90
+ pass
91
+ # float conversion
92
+ if param_annotation == float :
93
+ try :
94
+ user_input = float (user_input )
95
+ except ValueError :
96
+ pass
97
+ # bool conversion
98
+ elif param_annotation == bool :
99
+ if user_input .lower () == "true" :
100
+ user_input = True
101
+ elif user_input .lower () == "false" :
102
+ user_input = False
103
+
83
104
# Check if type matches annotation
84
105
annotation_is_list = False
85
106
if hasattr (param_annotation , "_name" ):
Original file line number Diff line number Diff line change 11
11
12
12
setup (
13
13
name = 'Flask-Parameter-Validation' ,
14
- version = '1.0.17 ' ,
14
+ version = '1.0.18 ' ,
15
15
url = 'https://github.com/Ge0rg3/Flask-Parameter-Validation' ,
16
16
license = 'MIT' ,
17
17
author = 'George Omnet' ,
You can’t perform that action at this time.
0 commit comments