API

JSON validation

sanic_validation.validate_json(schema, clean=False)

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

Querystring validation

sanic_validation.validate_args(schema, clean=False)

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