@@ -263,19 +263,18 @@ def validate(self, mandatory: bool = None, repeat: int = None) -> None:
263263 for index , value in enumerate (self .elements ):
264264 current_schema = self .schema [index ]
265265 TemplateClass = current_schema [0 ]
266+ # If data structure representation is not overridden, use
267+ # the default value of the DataElement class.
268+ data_struct_representation = getattr (TemplateClass , "repr" , None )
266269 if len (current_schema ) > 1 :
267- if not mandatory :
270+ if mandatory is None :
268271 # If mandatory is not set, use the default value from the schema,
269272 # or assume True if not set.
270- mandatory = (
271- (current_schema [1 ] == "M" ) if len (current_schema ) > 1 else True
272- )
273- # If data structure representation is not overridden, use
274- # the default value from the schema
273+ mandatory = current_schema [1 ] == M
275274 elif len (current_schema ) > 2 :
275+ # override representation if set in schema
276276 data_struct_representation = current_schema [2 ]
277- else :
278- data_struct_representation = getattr (TemplateClass , "repr" , None )
277+
279278 if mandatory :
280279 # FIXME: even if not mandatory, but present, validation should be done.
281280 TemplateClass (value ).validate (
0 commit comments