API¶
JSON validation¶
-
sanic_validation.
validate_json
(schema, clean=False, status_code=400)[source]¶ Decorator. Validates request body json.
When clean is true, normalized data is passed to the decorated method as valid_json.
Parameters: - schema (dict) – Cerberus-compatible schema description
- clean (bool) – should cleaned json be passed to the decorated method
- status_code (number) – status code to return when data is incorrect
Querystring validation¶
-
sanic_validation.
validate_args
(schema, clean=False, status_code=400)[source]¶ Decorator. Validates querystring arguments.
When clean is True, normalized data is passed to the decorated method as valid_args.
Parameters: - schema (dict) – Cerberus-compatible schema description
- clean (bool) – should cleaned args be passed to the decorated method
- status_code (number) – status code to return when data is incorrect