Strip blank spaces
This commit is contained in:
1 parent
378ba67410
commit
a5960e4d8d
1 file changed
+10
-1
+10
-1
@@ -1,10 +1,19 @@
|
|||||||
from pydantic import BaseModel, Field, computed_field
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
from pydantic import BaseModel, Field, computed_field, field_validator
|
||||||
|
|
||||||
|
|
||||||
class AnimeCreate(BaseModel):
|
class AnimeCreate(BaseModel):
|
||||||
anilist_id: int = Field(gt=0)
|
anilist_id: int = Field(gt=0)
|
||||||
custom_name: str | None = Field(default=None, max_length=255)
|
custom_name: str | None = Field(default=None, max_length=255)
|
||||||
|
|
||||||
|
@field_validator("custom_name", mode="before")
|
||||||
|
@classmethod
|
||||||
|
def blank_to_none(cls, value):
|
||||||
|
if isinstance(value, str):
|
||||||
|
return value.strip() or None
|
||||||
|
return value
|
||||||
|
|
||||||
class AnimeRemove(BaseModel):
|
class AnimeRemove(BaseModel):
|
||||||
anilist_id: int
|
anilist_id: int
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user