Add data validation
This commit is contained in:
parent
859a962aac
commit
d8aa54659f
|
@ -31,8 +31,14 @@ def post_time():
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
return 'Error: JSON decode error:\n' + str(e), 400
|
return 'Error: JSON decode error:\n' + str(e), 400
|
||||||
|
|
||||||
# TODO: JSON schema validation
|
if not ('name' in data and 'agreetoguidelines' in data):
|
||||||
# TODO: JSON content validation
|
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'])
|
name = slugify(data['name'])
|
||||||
|
|
||||||
now = datetime.utcnow()
|
now = datetime.utcnow()
|
||||||
|
|
Loading…
Reference in New Issue