Add validation constraints to image.settings

Created on 20 October 2023, about 1 year ago
Updated 11 July 2024, 5 months ago

Problem/Motivation

Image settings have 1 property paths that are not yet validatable:

./vendor/bin/drush config:inspect --filter-keys=image.settings --detail --list-constraints  --fields=key,validatability,constraints
➜  🤖 Analyzing…

 -------------------------------------------- ------------- ------------------------------------------ 
  Key                                          Validatable   Validation constraints                    
 -------------------------------------------- ------------- ------------------------------------------ 
  image.settings                               83%           ValidKeys: '<infer>'                      
                                                             RequiredKeys: '<infer>'                   
   image.settings:                             Validatable   ValidKeys: '<infer>'                      
                                                             RequiredKeys: '<infer>'                   
   image.settings:_core                        Validatable   ValidKeys:                                
                                                               - default_config_hash                   
                                                             RequiredKeys: '<infer>'                   
   image.settings:_core.default_config_hash    Validatable   NotNull: {  }                             
                                                             Regex: '/^[a-zA-Z0-9\-_]+$/'              
                                                             Length: 43                                
                                                             ↣ PrimitiveType: {  }                     
   image.settings:allow_insecure_derivatives   Validatable   ↣ PrimitiveType: {  }                     
   image.settings:preview_image                NOT           ⚠️  @todo Add validation constraints here  
   image.settings:suppress_itok_output         Validatable   ↣ PrimitiveType: {  }                     
 -------------------------------------------- ------------- ------------------------------------------ 

Steps to reproduce

  1. Get a local git clone of Drupal core 11.x.
  2. composer require drupal/config_inspector — or manually install https://www.drupal.org/project/config_inspector/releases/2.1.5 or newer (which supports Drupal 11!)
  3. composer require drush/drush
  4. vendor/bin/drush config:inspect --filter-keys=olivero.settings --detail --list-constraints

Proposed resolution

Add validation constraints to:

  1. preview_image

This requires looking at the existing code and admin UI (if any) to understand which values could be considered valid. Eventually this needs to be reviewed by the relevant subsystem maintainer.

For examples, search *.schema.yml files for the string constraints: 😊

Reach out to @borisson_ or @wimleers in the #distributions-and-recipes.

Remaining tasks

  1. preview_image

User interface changes

None.

API changes

Adds a new ImageFilePath constraint plugin, that checks a given strings is a valid image.

Data model changes

More validation 🚀

Release notes snippet

None.

📌 Task
Status

Needs work

Version

11.0 🔥

Component
Image system 

Last updated 1 day ago

Created by

🇧🇪Belgium borisson_ Mechelen, 🇧🇪

Live updates comments and jobs are added and updated live.
  • API addition

    Enhances an existing API or introduces a new subsystem. Depending on the size and impact, possibly backportable to earlier major versions.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024