Skip to content

Commit ec16774

Browse files
committed
[section/property] Filter cardinality validation
1 parent 281461e commit ec16774

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

odml/property.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,11 +569,12 @@ def _values_cardinality_validation(self):
569569
is respected and prints a warning message otherwise.
570570
"""
571571
valid = validation.Validation(self)
572+
val_id = validation.ValidationID.property_values_cardinality
572573

573574
# Make sure to display only warnings of the current property
574-
res = [curr for curr in valid.errors if self.id == curr.obj.id]
575-
for err in res:
576-
print("%s: %s" % (err.rank.capitalize(), err.msg))
575+
for curr in valid.errors:
576+
if curr.validation_id == val_id and self.id == curr.obj.id:
577+
print("%s: %s" % (curr.rank.capitalize(), curr.msg))
577578

578579
def set_values_cardinality(self, min_val=None, max_val=None):
579580
"""

odml/section.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,12 @@ def _sections_cardinality_validation(self):
416416
is respected and prints a warning message otherwise.
417417
"""
418418
valid = validation.Validation(self)
419+
val_id = validation.ValidationID.section_sections_cardinality
420+
419421
# Make sure to display only warnings of the current section
420-
res = [curr for curr in valid.errors if self.id == curr.obj.id]
421-
for err in res:
422-
print("%s: %s" % (err.rank.capitalize(), err.msg))
422+
for curr in valid.errors:
423+
if curr.validation_id == val_id and self.id == curr.obj.id:
424+
print("%s: %s" % (curr.rank.capitalize(), curr.msg))
423425

424426
@property
425427
def prop_cardinality(self):
@@ -469,10 +471,12 @@ def _properties_cardinality_validation(self):
469471
is respected and prints a warning message otherwise.
470472
"""
471473
valid = validation.Validation(self)
474+
val_id = validation.ValidationID.section_properties_cardinality
475+
472476
# Make sure to display only warnings of the current section
473-
res = [curr for curr in valid.errors if self.id == curr.obj.id]
474-
for err in res:
475-
print("%s: %s" % (err.rank.capitalize(), err.msg))
477+
for curr in valid.errors:
478+
if curr.validation_id == val_id and self.id == curr.obj.id:
479+
print("%s: %s" % (curr.rank.capitalize(), curr.msg))
476480

477481
@inherit_docstring
478482
def get_terminology_equivalent(self):

0 commit comments

Comments
 (0)