File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed
packages/models-library/src/models_library Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change 1010from common_library .basic_types import DEFAULT_FACTORY
1111from pydantic import (
1212 BaseModel ,
13+ BeforeValidator ,
1314 ConfigDict ,
1415 Field ,
1516 HttpUrl ,
@@ -85,13 +86,17 @@ class BaseProjectModel(BaseModel):
8586 ]
8687 description : Annotated [
8788 str ,
89+ BeforeValidator (none_to_empty_str_pre_validator ),
8890 Field (
8991 description = "longer one-line description about the project" ,
9092 examples = ["Dabbling in temporal transitions ..." ],
9193 ),
9294 ]
9395 thumbnail : Annotated [
9496 HttpUrl | None ,
97+ BeforeValidator (
98+ empty_str_to_none_pre_validator ,
99+ ),
95100 Field (
96101 description = "url of the project thumbnail" ,
97102 examples = ["https://placeimg.com/171/96/tech/grayscale/?0.jpg" ],
@@ -105,15 +110,6 @@ class BaseProjectModel(BaseModel):
105110 # FIXME: pedro removes this one
106111 workbench : Annotated [NodesDict , Field (description = "Project's pipeline" )]
107112
108- # validators
109- _empty_thumbnail_is_none = field_validator ("thumbnail" , mode = "before" )(
110- empty_str_to_none_pre_validator
111- )
112-
113- _none_description_is_empty = field_validator ("description" , mode = "before" )(
114- none_to_empty_str_pre_validator
115- )
116-
117113
118114class ProjectAtDB (BaseProjectModel ):
119115 # Model used to READ from database
You can’t perform that action at this time.
0 commit comments