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"
        }
    ]
}

Metadata

Release files for faust-pydantic-validate 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for faust-pydantic-validate 0.0.2
File Size Uploaded
faust_pydantic_validate-0.0.2.tar.gz 2.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for faust-pydantic-validate 0.0.2
File Interpreter ABI Platform
faust_pydantic_validate-0.0.2-py3.9.egg Legacy Egg format - - Details
faust_pydantic_validate-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.2 kB

Release files / faust_pydantic_validate-0.0.2.tar.gz

Download URL faust_pydantic_validate-0.0.2.tar.gz
Size 2.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b65342ac31533835cb2870b280e1e08d000814035b64d9d676a01e7569024ff9
BLAKE2b-256 checksum
How to use checksums
6d14fb726cbb1fe5560896f67cb17c14ffeb097cd6a99c880fee85727ddaf3ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0

Release files / faust_pydantic_validate-0.0.2-py3.9.egg

Download URL faust_pydantic_validate-0.0.2-py3.9.egg
Size 3.9 kB
Tags Egg
SHA-256 checksum
How to use checksums
bbd1e5135c949b4755720b8f614ac172b683af9d14a09fc1736f66e86596b3ad
BLAKE2b-256 checksum
How to use checksums
90d53d992072bd42bdf341e6f34d30a1d6d584edb8394e78f2013fd817a1b1e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0

Release files / faust_pydantic_validate-0.0.2-py3-none-any.whl

Download URL faust_pydantic_validate-0.0.2-py3-none-any.whl
Size 2.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3563b40ea74fadc1e00b1c8caa2c7af370547bd06d277ac2007c1a5fafa3d960
BLAKE2b-256 checksum
How to use checksums
3f2c9f48755808c4a78e903809e23b1f0c8592b72ce0feb9a3e86c98a8c390d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0

Release history Release notifications | RSS feed

This release

0.0.2 This release

3 release files

0.0.1

3 release 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