Skip to content

Commit ed773b0

Browse files
committed
Simplify codes.
1 parent 1187cb3 commit ed773b0

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

src/mavedb/view_models/experiment.py

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,29 +73,11 @@ def validate_keywords(cls, v):
7373
keywords.validate_keywords(v)
7474
return v
7575

76-
@validator("title")
77-
def validate_title(cls, v):
76+
@validator("title", "short_description", "abstract_text", "method_text")
77+
def validate_field_is_non_empty(cls, v, field):
7878
if is_null(v) or not isinstance(v, str):
79-
raise ValidationError("Invalid title. Title should not be None or space.")
80-
return v
81-
82-
@validator("short_description")
83-
def validate_short_description(cls, v):
84-
if is_null(v) or not isinstance(v, str):
85-
raise ValidationError("Invalid short description. Short description should not be None or space.")
86-
return v
87-
88-
@validator("abstract_text")
89-
def validate_abstract_text(cls, v):
90-
if is_null(v) or not isinstance(v, str):
91-
raise ValidationError("Invalid abstract text. Abstract text should not be None or space.")
92-
return v
93-
94-
@validator("method_text")
95-
def validate_method_text(cls, v):
96-
if is_null(v) or not isinstance(v, str):
97-
raise ValidationError("Invalid method text. Method text should not be None or space.")
98-
return v
79+
raise ValidationError("This field is required and cannot be empty.")
80+
return v.strip()
9981

10082

10183
class ExperimentCreate(ExperimentModify):

0 commit comments

Comments
 (0)