Add data validation

This commit is contained in:
Oskar Winkels 2020-11-30 21:53:09 +01:00 committed by Oskar
parent 859a962aac
commit d8aa54659f
1 changed files with 8 additions and 2 deletions

View File

@ -31,8 +31,14 @@ def post_time():
except ValueError as e:
return 'Error: JSON decode error:\n' + str(e), 400
# TODO: JSON schema validation
# TODO: JSON content validation
if not ('name' in data and 'agreetoguidelines' in data):
return "Error: Key missing. See docs/API.md for reference.", 400
if not data['agreetoguidelines']:
return "Error: Didn't agree to guidelines.", 406
name = slugify(data['name'])
now = datetime.utcnow()