Add validation constraints to system.site

Created on 25 April 2024, 7 months ago
Updated 18 July 2024, 4 months ago

Problem/Motivation

system.site has 5 property path that are not yet validatable:

vendor/bin/drush config:inspect --filter-keys=system.site --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                                                                       
 ---------------------------------------- --------- ------------- ------ --------------------------------------------------------------------------------------------- 
  system.site                              Correct   69%           โœ…โ“   ValidKeys: '<infer>'                                                                         
                                                                          LangcodeRequiredIfTranslatableValues: null                                                   
   system.site:                            Correct   Validatable   โœ…โœ…   ValidKeys: '<infer>'                                                                         
                                                                          LangcodeRequiredIfTranslatableValues: null                                                   
   system.site:_core                       Correct   Validatable   โœ…โœ…   ValidKeys:                                                                                   
                                                                            - default_config_hash                                                                      
   system.site:_core.default_config_hash   Correct   Validatable   โœ…โœ…   NotNull: {  }                                                                                
                                                                          Regex: '/^[a-zA-Z0-9\-_]+$/'                                                                 
                                                                          Length: 43                                                                                   
                                                                          โ†ฃ PrimitiveType: {  }                                                                        
   system.site:admin_compact_mode          Correct   Validatable   โœ…โœ…   โ†ฃ PrimitiveType: {  }                                                                        
   system.site:default_langcode            Correct   Validatable   โœ…โœ…   NotNull: {  }                                                                                
                                                                          Choice:                                                                                      
                                                                            callback: 'Drupal\Core\TypedData\Plugin\DataType\LanguageReference::getAllValidLangcodes'  
                                                                          โ†ฃ PrimitiveType: {  }                                                                        
   system.site:langcode                    Correct   Validatable   โœ…โœ…   NotNull: {  }                                                                                
                                                                          Choice:                                                                                      
                                                                            callback: 'Drupal\Core\TypedData\Plugin\DataType\LanguageReference::getAllValidLangcodes'  
                                                                          โ†ฃ PrimitiveType: {  }                                                                        
   system.site:mail                        Correct   Validatable   โœ…โœ…   Email:                                                                                       
                                                                            message: '%value is not a valid email address.'                                            
                                                                          โ†ฃ PrimitiveType: {  }                                                                        
   system.site:mail_notification           Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here                                                    
   system.site:name                        Correct   Validatable   โœ…โœ…   Regex:                                                                                       
                                                                            pattern: '/([^\PC])/u'                                                                     
                                                                            match: false                                                                               
                                                                            message: 'Labels are not allowed to span multiple lines or contain control characters.'    
                                                                          โ†ฃ PrimitiveType: {  }                                                                        
   system.site:page                        Correct   Validatable   โœ…โœ…   ValidKeys: '<infer>'                                                                         
   system.site:page.403                    Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here                                                    
   system.site:page.404                    Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here                                                    
   system.site:page.front                  Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here                                                    
   system.site:slogan                      Correct   Validatable   โœ…โœ…   Regex:                                                                                       
                                                                            pattern: '/([^\PC])/u'                                                                     
                                                                            match: false                                                                               
                                                                            message: 'Labels are not allowed to span multiple lines or contain control characters.'    
                                                                          โ†ฃ PrimitiveType: {  }                                                                        
   system.site:uuid                        Correct   Validatable   โœ…โœ…   Uuid: {  }                                                                                   
                                                                          NotNull: {  }                                                                                
                                                                          โ†ฃ PrimitiveType: {  }                                                                        
   system.site:weight_select_max           Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here                                                    
 ---------------------------------------- --------- ------------- ------ --------------------------------------------------------------------------------------------- 

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=system.site --detail --list-constraints

Proposed resolution

Add validation constraints to:

  1. system.site:mail_notification
  2. system.site:page.403
  3. system.site:page.404
  4. system.site:page.front
  5. system.site:weight_select_max

For examples, search *.schema.yml files for the string constraints: ๐Ÿ˜Š

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

Remaining tasks

User interface changes

None.

API changes

Data model changes

More validation ๐Ÿš€

Release notes snippet

None.

๐Ÿ“Œ Task
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Systemย  โ†’

Last updated 6 days ago

No maintainer
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