Created
December 16, 2015 03:28
-
-
Save pcote/37e51134d50b47802258 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def validate_json(*expected_args): | |
def decorator(func): | |
@wraps(func) | |
def wrapper(*args, **kwargs): | |
json_ob = request.get_json() | |
for expected_arg in expected_args: | |
if expected_arg not in json_ob or json_ob.get(expected_arg) is None: | |
abort(400) | |
return func(*args, **kwargs) | |
return wrapper | |
return decorator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment