/sanic-validation

Validation for sanic endpoints

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

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