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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| faust_pydantic_validate-0.0.1.tar.gz | 2.5 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| faust_pydantic_validate-0.0.1-py3.8.egg | Legacy Egg format | - | - | Details |
| faust_pydantic_validate-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.0 kB
Release files / faust_pydantic_validate-0.0.1.tar.gz
| Download URL | faust_pydantic_validate-0.0.1.tar.gz |
|---|---|
| Size | 2.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dafe616cef0d70a23a9ed2fd0f1efad80490dfa062ea0463503981d92742484e
|
|
BLAKE2b-256 checksum How to use checksums |
d77d1ea3235132780e3aa4a46d83546554f513db225c837c581b7077da691d05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / faust_pydantic_validate-0.0.1-py3.8.egg
| Download URL | faust_pydantic_validate-0.0.1-py3.8.egg |
|---|---|
| Size | 6.1 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
569877656397ffa3824e8726209d8c38b4209d7a104ec67c3282c99f2e671a40
|
|
BLAKE2b-256 checksum How to use checksums |
b1e49b370861de11c768b2a0f46b9248c7a952eebc8e097a6cf7a93e5fbbf1f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / faust_pydantic_validate-0.0.1-py3-none-any.whl
| Download URL | faust_pydantic_validate-0.0.1-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0683d261a50c30afed48ee636a60afbae845c2b8bef6c7108250aedd03a15eeb
|
|
BLAKE2b-256 checksum How to use checksums |
cb0d649fd0a6868d673d0e6fecc48bf8eb519b6ec264ab1978031b5964e0760e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|