File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -394,6 +394,31 @@ def sec_cardinality(self, new_value):
394394 """
395395 self ._sec_cardinality = format_cardinality (new_value )
396396
397+ # Validate and inform user if the current cardinality is violated
398+ self ._sections_cardinality_validation ()
399+
400+ def set_sections_cardinality (self , min_val = None , max_val = None ):
401+ """
402+ Sets the Sections cardinality of a Section.
403+
404+ :param min_val: Required minimal number of values elements. None denotes
405+ no restrictions on values elements minimum. Default is None.
406+ :param max_val: Allowed maximal number of values elements. None denotes
407+ no restrictions on values elements maximum. Default is None.
408+ """
409+ self .sec_cardinality = (min_val , max_val )
410+
411+ def _sections_cardinality_validation (self ):
412+ """
413+ Runs a validation to check whether the sections cardinality
414+ is respected and prints a warning message otherwise.
415+ """
416+ valid = validation .Validation (self )
417+ # Make sure to display only warnings of the current section
418+ res = [curr for curr in valid .errors if self .id == curr .obj .id ]
419+ for err in res :
420+ print ("%s: %s" % (err .rank .capitalize (), err .msg ))
421+
397422 @property
398423 def prop_cardinality (self ):
399424 """
You can’t perform that action at this time.
0 commit comments