Add usage example for custom media url

This commit is contained in:
Yerassyl Zhanymkanov
2022-08-19 16:31:20 +06:00
parent 04a0ea4fa2
commit 4b2b3a4b3f

View File

@@ -688,7 +688,7 @@ class Post(BaseModel):
### 22. Validate url source (if users are able to upload files) ### 22. Validate url source (if users are able to upload files)
Bad users could send strange urls for user facing public objects. Bad users could send strange urls for user facing public objects.
```python ```python
from pydantic import AnyUrl from pydantic import AnyUrl, BaseModel
ALLOWED_MEDIA_URLS = {"mysite.com", "mysite.org"} ALLOWED_MEDIA_URLS = {"mysite.com", "mysite.org"}
@@ -702,6 +702,11 @@ class CompanyMediaUrl(AnyUrl):
) )
return host, tld, host_type, rebuild return host, tld, host_type, rebuild
class Post(BaseModel):
thumbnail_url: CompanyMediaUrl
``` ```
### 23. root_validator to use multiple columns during validation ### 23. root_validator to use multiple columns during validation
```python ```python