Add validation constraints to language.content_settings.*.*

Created on 1 July 2024, 6 months ago
Updated 6 August 2024, 5 months ago

Problem/Motivation

ContentLanguageSettings entity is not yet fully validatable:

.vendor/bin/drush config:inspect --filter-keys=language.content_settings.node.article --detail --list-constraints
โžœ  ๐Ÿค– Analyzingโ€ฆ

 Legend for Data: 
  โœ…โ“  โ†’ Correct primitive type, detailed validation impossible.
  โœ…โœ…  โ†’ Correct primitive type, passed all validation constraints.
 ------------------------------------------------------------------------------------------ --------- ------------- ------ --------------------------------------------------------------------------------------------- 
  Key                                                                                        Status    Validatable   Data   Validation constraints                                                                       
 ------------------------------------------------------------------------------------------ --------- ------------- ------ --------------------------------------------------------------------------------------------- 
  language.content_settings.node.article                                                     Correct   74%           โœ…โ“   ValidKeys: '<infer>'                                                                         
   language.content_settings.node.article:                                                   Correct   Validatable   โœ…โœ…   ValidKeys: '<infer>'                                                                         
   language.content_settings.node.article:_core                                              Correct   Validatable   โœ…โœ…   ValidKeys:                                                                                   
                                                                                                                              - default_config_hash                                                                      
   language.content_settings.node.article:_core.default_config_hash                          Correct   Validatable   โœ…โœ…   NotNull: {  }                                                                                
                                                                                                                            Regex: '/^[a-zA-Z0-9\-_]+$/'                                                                 
                                                                                                                            Length: 43                                                                                   
                                                                                                                            โ†ฃ PrimitiveType: {  }                                                                        
   language.content_settings.node.article:default_langcode                                   Correct   Validatable   โœ…โœ…   Choice:                                                                                      
                                                                                                                              callback: '\Drupal\language\Entity\ContentLanguageSettings::getAllValidDefaultLangcodes'   
                                                                                                                            โ†ฃ PrimitiveType: {  }                                                                        
                                                                                                                            โ†ฃ NotNull: {  }                                                                              
   language.content_settings.node.article:dependencies                                       Correct   Validatable   โœ…โœ…   ValidKeys: '<infer>'                                                                         
   language.content_settings.node.article:dependencies.config                                Correct   NOT           โœ…โ“   โŒ @todo Add validation constraints to ancestor type: config_dependencies                    
   language.content_settings.node.article:dependencies.config.0                              Correct   Validatable   โœ…โœ…   NotBlank: {  }                                                                               
                                                                                                                            ConfigExists: {  }                                                                           
                                                                                                                            โ†ฃ PrimitiveType: {  }                                                                        
   language.content_settings.node.article:dependencies.module                                Correct   NOT           โœ…โ“   โŒ @todo Add validation constraints to ancestor type: config_dependencies                    
   language.content_settings.node.article:dependencies.module.0                              Correct   Validatable   โœ…โœ…   NotBlank: {  }                                                                               
                                                                                                                            ExtensionName: {  }                                                                          
                                                                                                                            ExtensionExists: module                                                                      
                                                                                                                            โ†ฃ PrimitiveType: {  }                                                                        
   language.content_settings.node.article:id                                                 Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints to config entity type: language.content_settings.*.*    
   language.content_settings.node.article:langcode                                           Correct   Validatable   โœ…โœ…   NotNull: {  }                                                                                
                                                                                                                            Choice:                                                                                      
                                                                                                                              callback: 'Drupal\Core\TypedData\Plugin\DataType\LanguageReference::getAllValidLangcodes'  
                                                                                                                            โ†ฃ PrimitiveType: {  }                                                                        
   language.content_settings.node.article:language_alterable                                 Correct   Validatable   โœ…โœ…   โ†ฃ PrimitiveType: {  }                                                                        
   language.content_settings.node.article:status                                             Correct   Validatable   โœ…โœ…   โ†ฃ PrimitiveType: {  }                                                                        
   language.content_settings.node.article:target_bundle                                      Correct   Validatable   โœ…โœ…   EntityBundleExists: '%parent.target_entity_type_id'                                          
                                                                                                                            โ†ฃ PrimitiveType: {  }                                                                        
   language.content_settings.node.article:target_entity_type_id                              Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints to config entity type: language.content_settings.*.*    
   language.content_settings.node.article:third_party_settings                               Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints to config entity type: language.content_settings.*.*    
   language.content_settings.node.article:third_party_settings.content_translation           Correct   Validatable   โœ…โœ…   ValidKeys: '<infer>'                                                                         
   language.content_settings.node.article:third_party_settings.content_translation.enabled   Correct   Validatable   โœ…โœ…   โ†ฃ PrimitiveType: {  }                                                                        
   language.content_settings.node.article:uuid                                               Correct   Validatable   โœ…โœ…   Uuid: {  }                                                                                   
                                                                                                                            โ†ฃ 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. Install Demo: Umami profile./vendor/bin/drush si demo_umami -y
  5. vendor/bin/drush config:inspect --filter-keys=language.content_settings.node.article --detail --list-constraints

Proposed resolution

Add validation constraints to missing properties.

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 #recipes.

Remaining tasks

MR

User interface changes

None.

API changes

None.

Data model changes

More validation ๐Ÿš€

Release notes snippet

None.

๐Ÿ“Œ Task
Status

Fixed

Version

10.4 โœจ

Component
Language systemย  โ†’

Last updated about 16 hours ago

  • Maintained by
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany @sun
Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia narendraR Jaipur, India

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024