@@ -675,20 +675,9 @@ class NDText(NDBase):
675675 #No feature schema to check
676676
677677
678- class NDAnswer (BaseModel ):
679- schemaId : Optional [Cuid ] = None
680- value : Optional [str ] = None
681-
682- @root_validator
683- def must_set_one (cls , values ):
684- if values ['schemaId' ] is None and values ['value' ] is None :
685- raise ValueError ("Must set either schemaId or value for answers" )
686- return values
687-
688-
689678class NDChecklist (VideoSupported , NDBase ):
690679 ontology_type : Literal ["checklist" ] = "checklist"
691- answers : List [NDAnswer ] = pydantic .Field (determinant = True )
680+ answers : List [NDFeatureSchema ] = pydantic .Field (determinant = True )
692681
693682 @validator ('answers' , pre = True )
694683 def validate_answers (cls , value , field ):
@@ -704,7 +693,7 @@ def validate_feature_schemas(self, valid_feature_schemas_by_id,
704693 self ).validate_feature_schemas (valid_feature_schemas_by_id ,
705694 valid_feature_schemas_by_name )
706695 #Test the feature schemas provided to the answer field
707- if len (set ([answer .value or answer .schemaId for answer in self .answers
696+ if len (set ([answer .name or answer .schemaId for answer in self .answers
708697 ])) != len (self .answers ):
709698 raise ValueError (
710699 f"Duplicated featureSchema found for checklist { self .uuid } " )
@@ -713,15 +702,15 @@ def validate_feature_schemas(self, valid_feature_schemas_by_id,
713702 self .
714703 name ]['options' ] if self .name else valid_feature_schemas_by_id [
715704 self .schemaId ]['options' ]
716- if answer .value not in options and answer .schemaId not in options :
705+ if answer .name not in options and answer .schemaId not in options :
717706 raise ValueError (
718707 f"Feature schema provided to { self .ontology_type } invalid. Expected on of { options } . Found { answer } "
719708 )
720709
721710
722711class NDRadio (VideoSupported , NDBase ):
723712 ontology_type : Literal ["radio" ] = "radio"
724- answer : NDAnswer = pydantic .Field (determinant = True )
713+ answer : NDFeatureSchema = pydantic .Field (determinant = True )
725714
726715 def validate_feature_schemas (self , valid_feature_schemas_by_id ,
727716 valid_feature_schemas_by_name ):
@@ -731,9 +720,9 @@ def validate_feature_schemas(self, valid_feature_schemas_by_id,
731720 options = valid_feature_schemas_by_name [
732721 self .name ]['options' ] if self .name else valid_feature_schemas_by_id [
733722 self .schemaId ]['options' ]
734- if self .answer .value not in options and self .answer .schemaId not in options :
723+ if self .answer .name not in options and self .answer .schemaId not in options :
735724 raise ValueError (
736- f"Feature schema provided to { self .ontology_type } invalid. Expected on of { options } . Found { self .answer .value or self .answer .schemaId } "
725+ f"Feature schema provided to { self .ontology_type } invalid. Expected on of { options } . Found { self .answer .name or self .answer .schemaId } "
737726 )
738727
739728
0 commit comments