-
-
Save Sanix-Darker/d54639b0485f856f8ef2125df658acf0 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 validation_required(validator_function): | |
def decorator(function): | |
async def error(websocket, err): | |
await websocket.send(err) | |
async def wrapper(websocket, data): | |
status, err = validator_function(data) | |
if status: | |
return await function(websocket, data) | |
else: | |
return await error(websocket, err) | |
return wrapper | |
return decorator | |
def validate(data): | |
return True, "" | |
@validation_required(validate) | |
async def some_function(websocket, data): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment