Add validation constraints to config_entity.dependencies

Created on 28 November 2022, over 1 year ago
Updated 23 May 2023, about 1 year ago

Problem/Motivation

🌱 [META] Untie config validation from form validation β€” enables validatable Recipes, decoupled admin UIs … Active proposed to start using validation constraints for validating all config entities.

One of the generic aspects of config entities is this:

config_entity:
  type: mapping
  mapping:
…
    dependencies:
      type: config_dependencies
      label: 'Dependencies'
…

which is defined as:

config_dependencies_base:
  type: mapping
  mapping:
    config:
      type: sequence
      label: 'Configuration entity dependencies'
      sequence:
        type: string
    content:
      type: sequence
      label: 'Content entity dependencies'
      sequence:
        type: string
    module:
      type: sequence
      label: 'Module dependencies'
      sequence:
        type: string
    theme:
      type: sequence
      label: 'Theme dependencies'
      sequence:
        type: string

config_dependencies:
  type: config_dependencies_base
  label: 'Configuration dependencies'
  mapping:
    enforced:
      type: config_dependencies_base
      label: 'Enforced configuration dependencies'

If validation constraints are written for this, then … all config entities will already have some validation! Plus, it will help make validation "complete" for config entity types whose specific validation constraints are already written (first in line: πŸ“Œ [PP-1] Convert field_storage_config and field_config's form validation logic to validation constraints Postponed ).

Proposed resolution

  1. Validate that only supported top-level dependency types are specified.
  2. Validate that dependencies.config dependencies actually exist
  3. … do the same for dependencies.content, dependencies.module and dependencies.theme
  4. Stop using type: string for every case where the value is not just any string but a particular kind of string

Bonus (because not sure if actually feasible): if a config entity type is known to depend on another config entity (for example: a field_config entity always needs a field_storage_config entity β€” at minimum), but it doesn't specify such a dependency, fail validation in that case too.

Note: dependencies.enforced.* should then "just work"! 😊

Remaining tasks

TBD

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

Config dependencies now have validation constraints. β†’ These are not actively used by Drupal core, but will take effect as support is added for validating config entities at the data layer.

✨ Feature request
Status

Fixed

Version

10.1 ✨

Component
Configuration entityΒ  β†’

Last updated 4 days ago

Created by

πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

Live updates comments and jobs are added and updated live.
  • Contributed project blocker

    It denotes an issue that prevents porting of a contributed project to the stable version of Drupal due to missing APIs, regressions, and so on.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024