fix(models): reject combatant ids that misparse the transcript format
This commit is contained in:
@@ -410,6 +410,20 @@ class Combatant(_FrozenModel):
|
||||
raise ValueError(msg)
|
||||
return value
|
||||
|
||||
@field_validator("id")
|
||||
@classmethod
|
||||
def _validate_id(cls, value: str) -> str:
|
||||
# The transcript line format is "round N <id>: <message>"; an id
|
||||
# containing ": " would be mis-split by cli._parse_transcript_line,
|
||||
# and leading/trailing whitespace breaks the "id: " join.
|
||||
if not value or value != value.strip():
|
||||
msg = f"combatant id must be non-empty without surrounding whitespace, got {value!r}"
|
||||
raise ValueError(msg)
|
||||
if ": " in value:
|
||||
msg = f"combatant id must not contain ': ' (breaks transcript parsing), got {value!r}"
|
||||
raise ValueError(msg)
|
||||
return value
|
||||
|
||||
@property
|
||||
def is_lawful(self) -> bool:
|
||||
"""Law axis: LG/LN/LE."""
|
||||
|
||||
Reference in New Issue
Block a user