Skip to content

Commit

Permalink
Merge pull request #31 from Geode-solutions/feat_validate_request
Browse files Browse the repository at this point in the history
feat(functions): validate_request function
  • Loading branch information
JulienChampagnol authored Nov 6, 2023
2 parents 2a328b1 + 124c2f1 commit 8a55224
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/opengeodeweb_back/geode_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,15 @@ def extension_from_filename(filename):
return os.path.splitext(filename)[1][1:]


def form_variables(form, variables_array):
variables_dict = {}
def validate_request(request, variables_array):
json_data = request.get_json(force=True, silent=True)

if json_data is None:
flask.abort(400, f"No json sent")

for variable in variables_array:
if form.get(variable) is None:
if variable not in json_data.keys():
flask.abort(400, f"No {variable} sent")
else:
variables_dict[variable] = form.get(variable)
return variables_dict


def geographic_coordinate_systems(geode_object: str):
Expand Down

0 comments on commit 8a55224

Please sign in to comment.