Skip to content

Instantly share code, notes, and snippets.

@MarneeDear
Created March 25, 2015 22:23
Show Gist options
  • Save MarneeDear/7b7f87dda8019f1d433f to your computer and use it in GitHub Desktop.
Save MarneeDear/7b7f87dda8019f1d433f to your computer and use it in GitHub Desktop.
DECORATOR Validate activate user json
__author__ = 'marnee'
import functools
from validators import validate_user_schema
def validate_json(func):
def _decorator(json_obj, *args, **kwargs):
# validate json
if validate_user_schema.validate_activate_user(json_obj):
return func(json_obj)
else:
return False
return functools.wraps(func)(_decorator)
@validate_json
def process_json(json_obj):
user = json_obj['user']
print user
user_json = {
"user": {
"email": "email@email.com"
}
}
process_json(user_json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment