Skip to content

Commit

Permalink
Merge pull request #82 from BIH-CEI/72-datafieldvalue
Browse files Browse the repository at this point in the history
72 datafieldvalue
  • Loading branch information
frehburg authored Sep 18, 2024
2 parents 495dba1 + 1d0998c commit 35751b8
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/phenopacket_mapper/data_standards/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,27 @@ def __str__(self):

@dataclass(slots=True, frozen=True)
class DataFieldValue:
"""This class defines the value of a `DataField` in a `DataModelInstance`"""
"""This class defines the value of a `DataField` in a `DataModelInstance`
Equivalent to a cell value in a table.
:ivar field: DataField: The `DataField` to which this value belongs and which defines the value set for the field.
:ivar value: The value of the field.
"""
field: DataField
value: Union[int, float, str, bool, Date, CodeSystem]

def validate(self) -> bool:
"""Validates the data model instance based on data model definition
This method checks if the instance is valid based on the data model definition. It checks if all required fields
are present, if the values are in the value set, etc.
:return: True if the instance is valid, False otherwise
"""
# TODO: Implement this method
raise NotImplementedError


@dataclass(slots=True, frozen=True)
class DataModel:
Expand Down Expand Up @@ -174,5 +191,7 @@ def validate(self) -> bool:
:return: True if the instance is valid, False otherwise
"""
# TODO: Implement this method
raise NotImplementedError
for v in self.values:
if not v.validate():
return False
return True

0 comments on commit 35751b8

Please sign in to comment.