Skip to main content

Pydantic validation for Sanic framework

Project description

sanicpydantic

Pydantic validation for Sanic framework

Install:

pip install sanicpydantic

Example:

from pydantic import BaseModel
from sanic_pydantic import RequestValidator

validator = RequestValidator()

...

class QueryModel(BaseModel):
    str_param: str
    int_param: int
    bool_param: bool


@app.get('/')
@validator(query_schema=QueryModel)
def get_endpoint(request, query_: QueryModel):
    ...


class JsonModel(BaseModel):
    str_field: str
    int_field: int
    bool_field: bool


@app.post('/')
@validator(json_schema=JsonModel)
def post_endpoint(request, json_: JsonModel):
    ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sanicpydantic-0.0.3.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

sanicpydantic-0.0.3-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file sanicpydantic-0.0.3.tar.gz.

File metadata

  • Download URL: sanicpydantic-0.0.3.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for sanicpydantic-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b1972d8fc50f9b1fe4c0b0921bd9f7a72c1d6e00f4ed00ce39899ac6e8e58b42
MD5 a9dc9663ed92879f87c8df07b740c9a0
BLAKE2b-256 f710165b152276cb4ab36e76509a75695065eb8a530fd19b8f46d7faeca6e501

See more details on using hashes here.

File details

Details for the file sanicpydantic-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: sanicpydantic-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for sanicpydantic-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c761d73b82e854af97019dca804f762ae38c485cb63b0fe6eb38dd639208e90a
MD5 cafc5fbb07309848f256953c843bfbbf
BLAKE2b-256 78039811129547ff9829fd75366bf879505b85e57a037bb96dfa1f62bf873e5e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page