STAR-322: Extracting models to be able for converting themselves

This commit is contained in:
Daniel Schiavini 2018-12-05 14:08:40 +01:00
parent 163226f940
commit b693b9d98f
20 changed files with 324 additions and 254 deletions

View file

@ -8,6 +8,7 @@ class BaseModel:
self.__dict__.update(kwargs)
self.validate()
# Validates the model, raising an exception if the model is invalid.
def validate(self) -> None:
pass
@ -34,7 +35,9 @@ class LocalMaterial(BaseModel):
self.version = version # type: int
super().__init__(**kwargs)
#
def validate(self) -> None:
super().validate()
if not self.GUID:
raise ValueError("guid is required on LocalMaterial")
if not self.version: