Validation for sanic endpoints
Switch branches/tags
Clone or download
piotrb5e3 Merge pull request #8 from errietta/add_status_code
allow custom status code for errors
Latest commit 6cc5d47 Nov 8, 2018

README.md

sanic-validation

Build Status

sanic-validation is an extension to sanic that simplifies validating request data.

Installation

pip install sanic-validation

Documentation

Documentation is available at ReadTheDocs.

Usage example

from sanic import Sanic
from sanic.response import json
from sanic_validation import validate_json


app = Sanic()

schema = {'name': {'type': 'string', 'required': True}}


@app.route('/')
@validate_json(schema)
async def hello_service(request):
    return json({'message': 'Hello ' + request.json['name']})

app.run('0.0.0.0')

Building the documentation

Requirements

  • Python
  • Sphinx
  • make

Building

python setup.py install
cd docs
make html