Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
CameronSima committed Sep 11, 2024
1 parent 3cf4649 commit 354c243
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,23 +217,7 @@ async def get_user_handler(req: Request):

In this example, the endpoint expects username to be a string and age to be a float. If the parameters are missing or of the wrong type, a validation error is returned.

#### Example: Using Pydantic Models for Query Validation

```python
from pydantic import BaseModel
from ziplineio.validation.query import QueryParam, validate_query

class UserModel(BaseModel):
username: str
age: int

@app.get("/")
@validate_query(QueryParam("user", UserModel))
async def get_user_handler(req: Request):
user = req.query_params.get("user")
return {"user": user.model_dump()}

```
````
#### Example: Simple Body Parameter Validation
Expand All @@ -248,7 +232,7 @@ async def create_user_handler(req: Request):
age = req.body.get("age")
return {"username": username, "age": age}
```
````

#### Example: Using Pydantic Models for Body Validation

Expand Down

0 comments on commit 354c243

Please sign in to comment.