A small decorator for post data view validation
Project description
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"
}
]
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file faust_pydantic_validate-0.0.2.tar.gz.
File metadata
- Download URL: faust_pydantic_validate-0.0.2.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b65342ac31533835cb2870b280e1e08d000814035b64d9d676a01e7569024ff9
|
|
| MD5 |
fcd88aa016835a953ecae768e53ea846
|
|
| BLAKE2b-256 |
6d14fb726cbb1fe5560896f67cb17c14ffeb097cd6a99c880fee85727ddaf3ae
|
File details
Details for the file faust_pydantic_validate-0.0.2-py3.9.egg.
File metadata
- Download URL: faust_pydantic_validate-0.0.2-py3.9.egg
- Upload date:
- Size: 3.9 kB
- Tags: Egg
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbd1e5135c949b4755720b8f614ac172b683af9d14a09fc1736f66e86596b3ad
|
|
| MD5 |
d4b885946055849e1c261d0e83b685f5
|
|
| BLAKE2b-256 |
90d53d992072bd42bdf341e6f34d30a1d6d584edb8394e78f2013fd817a1b1e7
|
File details
Details for the file faust_pydantic_validate-0.0.2-py3-none-any.whl.
File metadata
- Download URL: faust_pydantic_validate-0.0.2-py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3563b40ea74fadc1e00b1c8caa2c7af370547bd06d277ac2007c1a5fafa3d960
|
|
| MD5 |
afdc4aff75cd261e5c34eac62e684956
|
|
| BLAKE2b-256 |
3f2c9f48755808c4a78e903809e23b1f0c8592b72ce0feb9a3e86c98a8c390d6
|