Add better wordings
This commit is contained in:
@@ -587,7 +587,6 @@ class Video(BaseModel):
|
|||||||
text: str | None
|
text: str | None
|
||||||
extra: str | None
|
extra: str | None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Post(BaseModel):
|
class Post(BaseModel):
|
||||||
content: Article | Video
|
content: Article | Video
|
||||||
@@ -596,7 +595,7 @@ class Post(BaseModel):
|
|||||||
post = Post(content={"video_id": 1, "text": "text"})
|
post = Post(content={"video_id": 1, "text": "text"})
|
||||||
print(type(post.content))
|
print(type(post.content))
|
||||||
# OUTPUT: Article
|
# OUTPUT: Article
|
||||||
# Because Article is very inclusive and all fields are optional
|
# Article is very inclusive and all fields are optional, allowing any dict to become valid
|
||||||
```
|
```
|
||||||
**Solutions:**
|
**Solutions:**
|
||||||
1. Not so bad solution. Order field types properly: from the most strict ones to loose ones.
|
1. Not so bad solution. Order field types properly: from the most strict ones to loose ones.
|
||||||
@@ -652,7 +651,8 @@ class Post(BaseModel):
|
|||||||
```
|
```
|
||||||
### 22. SQL-first, Pydantic-second
|
### 22. SQL-first, Pydantic-second
|
||||||
### 23. Validate file formats
|
### 23. Validate file formats
|
||||||
### 24. Validate url source (if users are able to send files)
|
### 24. Validate url source (if users are able to upload files)
|
||||||
|
Bad users could send strange urls for user facing public objects.
|
||||||
```python
|
```python
|
||||||
from pydantic import AnyUrl
|
from pydantic import AnyUrl
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user