Coverage for src/prosemark/domain/structural_element.py: 100%
15 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-09-28 19:17 +0000
« prev ^ index » next coverage.py v7.8.0, created at 2025-09-28 19:17 +0000
1"""Structural element value object for binder parsing.
3This module defines the StructuralElement value object for representing
4valid markdown list items with optional links.
5"""
7from dataclasses import dataclass
9from prosemark.domain.models import NodeId
12@dataclass(frozen=True)
13class StructuralElement:
14 """Represent a valid markdown list item with optional link.
16 This value object represents structural elements that define the binder
17 organization hierarchy, such as list items with UUID7 links.
18 """
20 indent_level: int
21 title: str
22 node_id: NodeId | None
23 line_number: int
25 def __post_init__(self) -> None:
26 """Validate StructuralElement field constraints."""
27 if self.indent_level < 0:
28 raise ValueError('indent_level must be non-negative')
30 if not self.title.strip():
31 raise ValueError('title must not be empty')
33 if self.line_number <= 0:
34 raise ValueError('line_number must be positive')