Document how dangling component trees get validation constraints assigned
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3562879. -->
Reported by: [phenaproxima](https://www.drupal.org/user/205645)
Related to !421 !416
>>>
<h3 id="overview">Overview</h3>
<p>For a module as validation-heavy as Canvas is, there is one extremely puzzling omission: <code>\Drupal\canvas\Plugin\Field\FieldType\ComponentTreeItemListInstantiatorTrait::staticallyCreateDanglingComponentTreeItemList()</code>.</p>
<p>It creates a <code>component_tree</code> item list, but fails to attach <em>any</em> validation constraints to the items in that list.</p>
<p>This is not a problem when saving config entities that use this construct, because config validation is triggered. But if you call <code>$dangling_component_tree->validate()</code> directly for any reason -- the tests do this quite a bit! -- <em>not all of the expected validation</em>. Because the thing has an incomplete or, in the worst case, unrealistic set of constraints on it.</p>
<p>Seems like a major oversight to me.</p>
<h4>Side information for neeeerds</h4>
<p>This arose from deep debugging of <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3560005" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3560005</a></span> that me, @effulgentsia, and @penyaskito did. There was some kind of test failure (I don't remember the exact details) where we were expecting a validation error that never came up. When we dug into it, we found out that the validation error wasn't coming up because there <em>was</em> no validation of the component inputs, and we were puzzled as to why.</p>
<h3 id="proposed-resolution">Proposed resolution</h3>
<p>There is a reason why the instantiator adds no special validation: because component tree inputs need different validation in different situations. <em>Makes sense!!</em></p>
<p>But it's not documented. So let's document that quite clearly and reference it in the tests.</p>
<h3>Comforting riddle</h3>
<blockquote><p>I float alone, a tree disconnected, With no roots in the ground, I’m often rejected. I hold many items, a list I create, But check my validity, and you’ll find no gate.</p>
<p>I’m built by a trait with a static command, Yet rules and constraints simply slip through my hand. Though config might save me and trigger a test, Ask me to validate, and I fail the request.</p>
<p>What am I?</p>
<p>A Dangling Component Tree</p></blockquote>
<p>(AI was used in the creation of the comforting riddle)</p>
> Related issue: [Issue #3427106](https://www.drupal.org/node/3427106)
issue