Skip to content

Commit 3d61fd9

Browse files
committed
Increase consistency and readability of feedback message in some check functions
1 parent dce953c commit 3d61fd9

5 files changed

Lines changed: 8 additions & 7 deletions

File tree

esdlvalidator/validation/functions/check_has_pair.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,18 @@ def execute(self):
3838
raise TypeError(f"Expect '{property}' to a string, got {type(p)}.")
3939

4040
msg = None
41+
entity_type = type(self.value).__name__
4142
if keyword in p:
4243
p_paired = p.replace(keyword, "")
4344
if p_paired not in properties:
44-
msg = f"{self.value.name} (id: {self.value.id}) does not have a paired entity with [{property}] = '{p_paired}'"
45+
msg = f"[{entity_type}] with [name] = '{self.value.name}' does not have a paired entity with [{property}] = '{p_paired}'"
4546
else:
4647
has_paired = any(
4748
keyword in item and item.replace(keyword, "") == p
4849
for item in properties
4950
)
5051
if not has_paired:
51-
msg = f"{self.value.name} (id: {self.value.id}) does not have a paired entity with [{property}] containing: '{p}' and '{keyword}'"
52+
msg = f"[{entity_type}] with [name] = '{self.value.name}' does not have a paired entity with [{property}] containing: '{p}' and '{keyword}'"
5253

5354
if msg:
5455
if self.args.get("resultMsgJSON"):

esdlvalidator/validation/functions/check_is_supported_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def execute(self):
3636

3737
if not supported_type:
3838
entity_type = type(self.value).__name__
39-
result = f"{self.value.id} is of type {entity_type}, which is not included in the supported types [{', '.join(types)}]."
39+
result = f"{self.value.name} is of type [{entity_type}], which is not included in the supported types [{', '.join(types)}]."
4040

4141
if self.args.get("resultMsgJSON"):
4242
msg = {"offending_asset": self.value.id, "message": result}

esdlvalidator/validation/functions/check_property_uniqueness.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def execute(self):
3030
if p is not None:
3131
counts = properties.count(p)
3232
if counts > 1:
33-
msg = f"{self.value.id} has a non-unique [{property}] ({p}), it occurs {counts} times in this ESDL"
33+
msg = f"[{property}] should be unique, but found ({counts}) assets with [{property}] = '{p}' in this ESDL."
3434
if self.args.get("resultMsgJSON"):
3535
result = { "offending_asset": self.value.id, "message": msg }
3636
return CheckResult(False, result)

esdlvalidator/validation/functions/check_reference_attributes_comparison.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ def execute(self):
126126
left_entity = self._resolve_reference(entity, left_args.get("ref"), results)
127127
right_entity = self._resolve_reference(entity, right_args.get("ref"), results)
128128

129-
left_val = self._get_attribute_value(left_entity, left_args, results)
130-
right_val = self._get_attribute_value(right_entity, right_args, results)
129+
left_val = self._get_attribute_value(left_entity, left_args, results) if left_entity else None
130+
right_val = self._get_attribute_value(right_entity, right_args, results) if right_entity else None
131131

132132
if left_val is not None and right_val is not None:
133133
results.extend(self._compare_values(left_val, right_val, operator, left_args, right_args))

esdlvalidator/validation/functions/check_reference_count_in_range.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def execute(self):
3232

3333
r = utils.get_attribute(self.value, referenceType)
3434
if r is None:
35-
raise ValueError(f"{self.value.id} ({self.value.name}) has no reference '{referenceType}'")
35+
raise ValueError(f"{self.value.name} (id: {self.value.id}) has no reference '{referenceType}'")
3636
if not isinstance(r, Iterable):
3737
raise TypeError(f"Reference '{referenceType}' is not iterable")
3838

0 commit comments

Comments
 (0)