Add validation constraints to language.entity.*

Created on 28 June 2024, 2 months ago
Updated 17 July 2024, about 2 months ago

Problem/Motivation

Language entity is not yet fully validatable:

.vendor/bin/drush config:inspect --filter-keys=language.entity.en --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.entity.en                              Correct   83%           โœ…โ“   ValidKeys: '<infer>'                                                                         
   language.entity.en:                            Correct   Validatable   โœ…โœ…   ValidKeys: '<infer>'                                                                         
   language.entity.en:_core                       Correct   Validatable   โœ…โœ…   ValidKeys:                                                                                   
                                                                                   - default_config_hash                                                                      
   language.entity.en:_core.default_config_hash   Correct   Validatable   โœ…โœ…   NotNull: {  }                                                                                
                                                                                 Regex: '/^[a-zA-Z0-9\-_]+$/'                                                                 
                                                                                 Length: 43                                                                                   
                                                                                 โ†ฃ PrimitiveType: {  }                                                                        
   language.entity.en:dependencies                Correct   Validatable   โœ…โœ…   ValidKeys: '<infer>'                                                                         
   language.entity.en:direction                   Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints to config entity type: language.entity.*                
   language.entity.en:id                          Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints to config entity type: language.entity.*                
   language.entity.en:label                       Correct   Validatable   โœ…โœ…   Regex:                                                                                       
                                                                                   pattern: '/([^\PC])/u'                                                                     
                                                                                   match: false                                                                               
                                                                                   message: 'Labels are not allowed to span multiple lines or contain control characters.'    
                                                                                 NotBlank: {  }                                                                               
                                                                                 โ†ฃ PrimitiveType: {  }                                                                        
   language.entity.en:langcode                    Correct   Validatable   โœ…โœ…   NotNull: {  }                                                                                
                                                                                 Choice:                                                                                      
                                                                                   callback: 'Drupal\Core\TypedData\Plugin\DataType\LanguageReference::getAllValidLangcodes'  
                                                                                 โ†ฃ PrimitiveType: {  }                                                                        
   language.entity.en:locked                      Correct   Validatable   โœ…โœ…   โ†ฃ PrimitiveType: {  }                                                                        
   language.entity.en:status                      Correct   Validatable   โœ…โœ…   โ†ฃ PrimitiveType: {  }                                                                        
   language.entity.en:uuid                        Correct   Validatable   โœ…โœ…   Uuid: {  }                                                                                   
                                                                                 โ†ฃ PrimitiveType: {  }                                                                        
   language.entity.en:weight                      Correct   Validatable   โœ…โœ…   Range:                                                                                       
                                                                                   min: -2147483648                                                                           
                                                                                   max: 2147483647                                                                            
                                                                                 FullyValidatable: null                                                                       
                                                                                 โ†ฃ 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 language module./vendor/bin/drush en language -y
  5. vendor/bin/drush config:inspect --filter-keys=language.entity.en --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

11.0 ๐Ÿ”ฅ

Component
Language systemย  โ†’

Last updated 1 day 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