Improve display of validation constraints: constraint IDs instead of FQCNs and local vs inherited
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3364412. -->
Reported by: [wim leers](https://www.drupal.org/user/99777)
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Quoting myself from <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/config_inspector/-/work_items/3216089" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/config_inspector/-/work_items/3216089</a></span> and <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/config_inspector/-/work_items/3216089" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/config_inspector/-/work_items/3216089</a></span>:</p>
<blockquote><p>
<strong>An idea for a follow-up could be to distinguish between inherited constraints vs local constraints — that would make it clear that for example the <code>_core</code> key (which is present in both <code>cdn.settings</code> and <code>media.settings</code>'s Drush output) actually is of the type <code>_core_config_info</code> — so adding a validation constraint <em>there</em> would fix it everywhere.</strong></p></blockquote>
<p>+</p>
<blockquote><p>
Another follow-up would be to map the FQCNs to the equivalent types:</p>
<ul>
<li><code>\Drupal\Core\Validation\Plugin\Validation\Constraint\PrimitiveTypeConstraint</code> would become <code>PrimitiveType</code> because of<br>
<pre> * @Constraint(<br> * id = "PrimitiveType",<br> * label = @Translation("Primitive type", context = "Validation")<br> * )</pre></li>
<li><code>\Drupal\cdn\Plugin\Validation\Constraint\CdnDomainConstraint</code> would become <code>CdnDomain</code> because of<br>
<pre> * @Constraint(<br> * id = "CdnDomain",<br> * label = @Translation("CDN domain", context = "Validation"),<br> * )</pre></li>
<li>and so on</li>
<p>… but that's really just a <em>nice-to-have</em> compared to today, where this information is still painfully difficult to access.
</p></ul></blockquote>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<h3 id="summary-ui-changes">User interface changes</h3>
<dl>
<dt>Before</dt>
<dd><img src="https://www.drupal.org/files/issues/2023-06-02/media.settings-before.png" alt=""><br>
</dd>
<dt>After</dt>
<dd>
<img src="https://www.drupal.org/files/issues/2023-06-02/media.settings-after.png" alt=""><br>
</dd>
</dl>
<dl>
<dt>Before</dt>
<dd><img src="https://www.drupal.org/files/issues/2023-06-02/cdn.settings-before.png" alt=""><br>
</dd>
<dt>After</dt>
<dd>
<img src="https://www.drupal.org/files/issues/2023-06-02/cdn.settings-after.png" alt=""><br>
</dd>
</dl>
<dl>
<dt>Before</dt>
<dd>
<pre>$ vendor/bin/drush config:inspect --filter-keys=cdn.settings --detail --list-constraints<br> ----------------------------------------- --------- ------------- ------- ----------------------------------------------------------------------------- <br> Key Status Validatable Data Validation constraints <br> ----------------------------------------- --------- ------------- ------- ----------------------------------------------------------------------------- <br> cdn.settings Correct 36% Valid <br> cdn.settings: Correct NOT Valid <br> cdn.settings:_core Correct NOT Valid <br> cdn.settings:_core.default_config_hash Correct NOT Valid <br> cdn.settings:farfuture Correct NOT Valid <br> cdn.settings:farfuture.status Correct Validatable Valid Drupal\Core\Validation\Plugin\Validation\Constraint\PrimitiveTypeConstraint <br> cdn.settings:langcode Correct NOT Valid <br> cdn.settings:mapping Correct NOT Valid <br> cdn.settings:mapping.conditions Correct NOT Valid <br> cdn.settings:mapping.domain Correct Validatable Valid Drupal\cdn\Plugin\Validation\Constraint\CdnDomainConstraint <br> Drupal\Core\Validation\Plugin\Validation\Constraint\PrimitiveTypeConstraint <br> cdn.settings:mapping.type Correct NOT Valid <br> cdn.settings:scheme Correct Validatable Valid Drupal\cdn\Plugin\Validation\Constraint\CdnSchemeConstraint <br> Drupal\Core\Validation\Plugin\Validation\Constraint\PrimitiveTypeConstraint <br> cdn.settings:status Correct Validatable Valid Drupal\Core\Validation\Plugin\Validation\Constraint\PrimitiveTypeConstraint <br> cdn.settings:stream_wrappers Correct NOT Valid <br> cdn.settings:stream_wrappers.0 Correct Validatable Valid Drupal\cdn\Plugin\Validation\Constraint\CdnStreamWrapperConstraint <br> Drupal\Core\Validation\Plugin\Validation\Constraint\PrimitiveTypeConstraint <br> ----------------------------------------- --------- ------------- ------- ----------------------------------------------------------------------------- </pre></dd>
<dt>After</dt>
<dd>
<pre>$ vendor/bin/drush config:inspect --filter-keys=cdn.settings --detail --list-constraints<br> Legend for Data: <br> ✅❓ → Correct primitive type, detailed validation impossible.<br> ✅✅ → Correct primitive type, passed all validation constraints.<br> ----------------------------------------- --------- ------------- ------ ------------------------ <br> Key Status Validatable Data Validation constraints <br> ----------------------------------------- --------- ------------- ------ ------------------------ <br> cdn.settings Correct 36% ✅❓ <br> cdn.settings: Correct NOT ✅❓ <br> cdn.settings:_core Correct NOT ✅❓ <br> cdn.settings:_core.default_config_hash Correct NOT ✅❓ <br> cdn.settings:farfuture Correct NOT ✅❓ <br> cdn.settings:farfuture.status Correct Validatable ✅✅ ↣ PrimitiveType: { } <br> cdn.settings:langcode Correct NOT ✅❓ <br> cdn.settings:mapping Correct NOT ✅❓ <br> cdn.settings:mapping.conditions Correct NOT ✅❓ <br> cdn.settings:mapping.domain Correct Validatable ✅✅ CdnDomain: { } <br> ↣ PrimitiveType: { } <br> cdn.settings:mapping.type Correct NOT ✅❓ <br> cdn.settings:scheme Correct Validatable ✅✅ CdnScheme: { } <br> ↣ PrimitiveType: { } <br> cdn.settings:status Correct Validatable ✅✅ ↣ PrimitiveType: { } <br> cdn.settings:stream_wrappers Correct NOT ✅❓ <br> cdn.settings:stream_wrappers.0 Correct Validatable ✅✅ CdnStreamWrapper: { } <br> ↣ PrimitiveType: { } <br> ----------------------------------------- --------- ------------- ------ ------------------------ </pre></dd>
</dl>
<h3 id="summary-api-changes">API changes</h3>
<p>N/A</p>
<h3 id="summary-data-model-changes">Data model changes</h3>
<p>N/A</p>
issue
GitLab AI Context
Project: project/config_inspector
Instance: https://git.drupalcode.org
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://git.drupalcode.org/project/config_inspector/-/raw/2.1.x/README.md — project overview and setup
Repository: https://git.drupalcode.org/project/config_inspector
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD