Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions nautobot_data_validation_engine/custom_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,10 @@ def compliance_result(self, message, attribute=None, valid=True):
"""Generate a DataCompliance object based on the given parameters."""
instance = self.context["object"]
attribute_value = None
if attribute:
if attribute and attribute.startswith("cf_"):
# Custom field attributes are prefixed with 'cf_'
attribute_value = instance.cf.get(attribute[3:], None)
elif attribute:
attribute_value = getattr(instance, attribute)
else:
attribute = "__all__"
Expand All @@ -295,7 +298,7 @@ def compliance_result(self, message, attribute=None, valid=True):
defaults={
"last_validation_date": self.result_date,
"validated_object_str": str(instance),
"validated_attribute_value": str(attribute_value) if attribute_value else "",
"validated_attribute_value": str(attribute_value)[:254] if attribute_value else "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! We should probably (at least in core/3.0) change this from a CharField to a TextField for more capability/flexibility.

"message": message,
"valid": valid,
},
Expand Down