capOverflowError method

ValidationError? capOverflowError(
  1. UiNode tree
)

Cap-overflow check (FR-002 acceptance 2). Public so the render tool can re-check after narrowing changes the cap.

Implementation

ValidationError? capOverflowError(UiNode tree) {
  final count = tree.nodeCount;
  if (count > nodeCap) {
    return ValidationError(
      ValidationErrorKind.capOverflow,
      'Tree has $count nodes; maximum allowed is $nodeCap.',
    );
  }
  return null;
}