Skip to main content

Dillinger

faust-pydantic-validate is a small decorator to validate post data.

Installation

pip install faust-pydantic-validate

Usage

from pydantic import BaseModel
from faust.types.web import Request, Response
from faust.web import View
from faust_pydantic_validate.wrappers import takes_pydantic

app = faust.App(
    'foo',
    broker='kafka://localhost:9092',
)


class FooBar(BaseModel):
    foobar: int


@app.page('/build/')
class Builder(View):

    @takes_pydantic(FooBar, include_schema=True)
    async def post(self, request: Request, validated_object: BaseModel, **kwargs: Any) -> Response:
        return self.json(value=validated_object.dict())


Request data
{
    "foobar": 1
}
Response data
{
    "foobar": 1
}

Request data
{
    "foobar": "foo"
}
Response data (include_schema=True)
    "errors": [
        {
            "loc": [
                "foobar"
            ],
            "msg": "value is not a valid integer",
            "type": "type_error.integer"
        }
    ],
    "schema": {
        "title": "FooBar",
        "type": "object",
        "properties": {
            "foobar": {
                "title": "Foobar",
                "type": "integer"
            }
        },
        "required": [
            "foobar"
        ]
    }
}
Response data (include_schema=False)
{
    "errors": [
        {
            "loc": [
                "foobar"
            ],
            "msg": "value is not a valid integer",
            "type": "type_error.integer"
        }
    ]
}

Download files

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

Source Distribution

faust_pydantic_validate-0.0.1.tar.gz (2.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

faust_pydantic_validate-0.0.1-py3.8.egg (6.1 kB view details)

Uploaded Egg

faust_pydantic_validate-0.0.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file faust_pydantic_validate-0.0.1.tar.gz.

File metadata

  • Download URL: faust_pydantic_validate-0.0.1.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for faust_pydantic_validate-0.0.1.tar.gz
Algorithm Hash digest
SHA256 dafe616cef0d70a23a9ed2fd0f1efad80490dfa062ea0463503981d92742484e
MD5 37e302ef50415842a79e7c7c3fc86d40
BLAKE2b-256 d77d1ea3235132780e3aa4a46d83546554f513db225c837c581b7077da691d05

See more details on using hashes here.

File details

Details for the file faust_pydantic_validate-0.0.1-py3.8.egg.

File metadata

  • Download URL: faust_pydantic_validate-0.0.1-py3.8.egg
  • Upload date:
  • Size: 6.1 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for faust_pydantic_validate-0.0.1-py3.8.egg
Algorithm Hash digest
SHA256 569877656397ffa3824e8726209d8c38b4209d7a104ec67c3282c99f2e671a40
MD5 006f43c3f50971590d73917bd8c12e7e
BLAKE2b-256 b1e49b370861de11c768b2a0f46b9248c7a952eebc8e097a6cf7a93e5fbbf1f1

See more details on using hashes here.

File details

Details for the file faust_pydantic_validate-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: faust_pydantic_validate-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for faust_pydantic_validate-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0683d261a50c30afed48ee636a60afbae845c2b8bef6c7108250aedd03a15eeb
MD5 c865ac3c2227fb7c6ad00e0c0fd7ce00
BLAKE2b-256 cb0d649fd0a6868d673d0e6fecc48bf8eb519b6ec264ab1978031b5964e0760e

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.2

3 files

This release

0.0.1 This release

3 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page