Skip to content

Commit 1187cb3

Browse files
committed
Debug #254 problem. Add validators of title, short description, abstract and methods in experiment.
1 parent d18a43e commit 1187cb3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/mavedb/view_models/experiment.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from mavedb.lib.validation import keywords
55
from mavedb.lib.validation.exceptions import ValidationError
6+
from mavedb.lib.validation.utilities import is_null
67
from mavedb.view_models import PublicationIdentifiersGetter
78
from mavedb.view_models.base.base import BaseModel, validator
89
from mavedb.view_models.doi_identifier import (
@@ -72,6 +73,30 @@ def validate_keywords(cls, v):
7273
keywords.validate_keywords(v)
7374
return v
7475

76+
@validator("title")
77+
def validate_title(cls, v):
78+
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
99+
75100

76101
class ExperimentCreate(ExperimentModify):
77102
experiment_set_urn: Optional[str]

0 commit comments

Comments
 (0)