Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293926

Add validation constraints to language.content_settings.*.*

$
0
0

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.


Viewing all articles
Browse latest Browse all 293926

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>