Skip to content
Merged
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions infrahub_sdk/convert_object_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def check_only_one_field(self) -> ConversionFieldValue:
fields = [self.attribute_value, self.peer_id, self.peers_ids]
set_fields = [f for f in fields if f is not None]
if len(set_fields) != 1:
raise ValueError("Exactly one of attribute_value, peer_id, or peers_ids must be set")
raise ValueError("Exactly one of `attribute_value`, `peer_id`, or `peers_ids` must be set")
return self


Expand All @@ -50,11 +50,11 @@ class ConversionFieldInput(BaseModel):

source_field: str | None = None
data: ConversionFieldValue | None = None
use_default_value: bool = False

@model_validator(mode="after")
def check_only_one_field(self) -> ConversionFieldInput:
if self.source_field is not None and self.data is not None:
raise ValueError("Only one of source_field or data can be set")
if self.source_field is None and self.data is None:
raise ValueError("Either source_field or data must be set")
fields_set = [self.source_field is not None, self.data is not None, self.use_default_value is True]
if sum(fields_set) != 1:
raise ValueError("Exactly one of `source_field`, `data` or `use_default_value` must be set")
return self