faust-pydantic-validate-0.0.2
توضیحات
A small decorator for post data view validation
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | faust-pydantic-validate-0.0.2 |
| نام | faust-pydantic-validate |
| نسخه کتابخانه | 0.0.2 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Alexey Kuzyashin |
| ایمیل نویسنده | alex@rocketcompute.com |
| آدرس صفحه اصلی | https://github.com/Kuzyashin/faust-pydantic-validate |
| آدرس اینترنتی | https://pypi.org/project/faust-pydantic-validate/ |
| مجوز | - |
# 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"
}
]
}
```
---
نیازمندی
| مقدار | نام |
|---|---|
| - | pydantic |
| - | faust-streaming |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl faust-pydantic-validate-0.0.2:
pip install faust-pydantic-validate-0.0.2.whl
نصب پکیج tar.gz faust-pydantic-validate-0.0.2:
pip install faust-pydantic-validate-0.0.2.tar.gz