Add config validation for workflow entities

Created on 2 November 2017, about 7 years ago
Updated 21 February 2024, 11 months ago

Problem/Motivation

Workflow config entities are partially validatable using the typed config system, but not quite. There are several properties that are not yet validatable:

$ ./vendor/bin/drush config:inspect --filter-keys=workflows.workflow.editorial --detail --list-constraints  --fields=key,validatability,constraints
➜  🤖 Analyzing…

 ------------------------------------------ ------------- --------------------------------------------------------------------------------- 
  Key                                        Validatable   Validation constraints                                                           
 ------------------------------------------ ------------- --------------------------------------------------------------------------------- 
  workflows.workflow.editorial               53%           ValidKeys: '<infer>'                                                             
   workflows.workflow.editorial:             Validatable   ValidKeys: '<infer>'                                                             
   workflows.workflow.editorial:_core        Validatable   ValidKeys:                                                                       
                                                             - default_config_hash                                                          
   workflows.workflow.editorial:_core.defa   Validatable   NotNull: {  }                                                                    
  ult_config_hash                                          Regex: '/^[a-zA-Z0-9\-_]+$/'                                                     
                                                           Length: 43                                                                       
                                                           ↣ PrimitiveType: {  }                                                            
   workflows.workflow.editorial:dependenci   Validatable   ValidKeys: '<infer>'                                                             
  es                                                                                                                                        
   workflows.workflow.editorial:dependenci   NOT           ❌ @todo Add validation constraints to ancestor type: config_dependencies        
  es.module                                                                                                                                 
   workflows.workflow.editorial:dependenci   Validatable   NotBlank: {  }                                                                   
  es.module.0                                              ExtensionName: {  }                                                              
                                                           ExtensionExists: module                                                          
                                                           ↣ PrimitiveType: {  }                                                            
   workflows.workflow.editorial:id           Validatable   Regex:                                                                           
                                                             pattern: '/^[a-z0-9_]+$/'                                                      
                                                             message: 'The %value machine name is not valid.'                               
                                                           Length:                                                                          
                                                             max: 166                                                                       
                                                           ↣ PrimitiveType: {  }                                                            
   workflows.workflow.editorial:label        Validatable   Regex:                                                                           
                                                             pattern: '/([^\PC])/u'                                                         
                                                             match: false                                                                   
                                                             message: 'Labels are not allowed to span multiple lines or contain control     
                                                           characters.'                                                                     
                                                           NotBlank: {  }                                                                   
                                                           ↣ PrimitiveType: {  }                                                            
   workflows.workflow.editorial:langcode     Validatable   NotNull: {  }                                                                    
                                                           Choice:                                                                          
                                                             callback:                                                                      
                                                           'Drupal\Core\TypedData\Plugin\DataType\LanguageReference::getAllValidLangcodes'  
                                                           ↣ PrimitiveType: {  }                                                            
   workflows.workflow.editorial:status       Validatable   ↣ PrimitiveType: {  }                                                            
   workflows.workflow.editorial:type         Validatable   PluginExists:                                                                    
                                                             manager: plugin.manager.workflows.type                                         
                                                             interface: Drupal\workflows\WorkflowTypeInterface                              
                                                           ↣ PrimitiveType: {  }                                                            
   workflows.workflow.editorial:type_setti   Validatable   ValidKeys: '<infer>'                                                             
  ngs                                                                                                                                       
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type:                            
  ngs.default_moderation_state                             workflow.type_settings.content_moderation                                        
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type:                            
  ngs.entity_types                                         workflow.type_settings.content_moderation                                        
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type:                            
  ngs.states                                               workflow.type_settings.content_moderation                                        
   workflows.workflow.editorial:type_setti   Validatable   ValidKeys: '<infer>'                                                             
  ngs.states.archived                                                                                                                       
   workflows.workflow.editorial:type_setti   Validatable   ↣ PrimitiveType: {  }                                                            
  ngs.states.archived.default_revision                                                                                                      
   workflows.workflow.editorial:type_setti   Validatable   Regex:                                                                           
  ngs.states.archived.label                                  pattern: '/([^\PC])/u'                                                         
                                                             match: false                                                                   
                                                             message: 'Labels are not allowed to span multiple lines or contain control     
                                                           characters.'                                                                     
                                                           ↣ PrimitiveType: {  }                                                            
   workflows.workflow.editorial:type_setti   Validatable   ↣ PrimitiveType: {  }                                                            
  ngs.states.archived.published                                                                                                             
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: content_moderation.state   
  ngs.states.archived.weight                                                                                                                
   workflows.workflow.editorial:type_setti   Validatable   ValidKeys: '<infer>'                                                             
  ngs.states.draft                                                                                                                          
   workflows.workflow.editorial:type_setti   Validatable   ↣ PrimitiveType: {  }                                                            
  ngs.states.draft.default_revision                                                                                                         
   workflows.workflow.editorial:type_setti   Validatable   Regex:                                                                           
  ngs.states.draft.label                                     pattern: '/([^\PC])/u'                                                         
                                                             match: false                                                                   
                                                             message: 'Labels are not allowed to span multiple lines or contain control     
                                                           characters.'                                                                     
                                                           ↣ PrimitiveType: {  }                                                            
   workflows.workflow.editorial:type_setti   Validatable   ↣ PrimitiveType: {  }                                                            
  ngs.states.draft.published                                                                                                                
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: content_moderation.state   
  ngs.states.draft.weight                                                                                                                   
   workflows.workflow.editorial:type_setti   Validatable   ValidKeys: '<infer>'                                                             
  ngs.states.published                                                                                                                      
   workflows.workflow.editorial:type_setti   Validatable   ↣ PrimitiveType: {  }                                                            
  ngs.states.published.default_revision                                                                                                     
   workflows.workflow.editorial:type_setti   Validatable   Regex:                                                                           
  ngs.states.published.label                                 pattern: '/([^\PC])/u'                                                         
                                                             match: false                                                                   
                                                             message: 'Labels are not allowed to span multiple lines or contain control     
                                                           characters.'                                                                     
                                                           ↣ PrimitiveType: {  }                                                            
   workflows.workflow.editorial:type_setti   Validatable   ↣ PrimitiveType: {  }                                                            
  ngs.states.published.published                                                                                                            
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: content_moderation.state   
  ngs.states.published.weight                                                                                                               
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type:                            
  ngs.transitions                                          workflow.type_settings.content_moderation                                        
   workflows.workflow.editorial:type_setti   Validatable   ValidKeys: '<infer>'                                                             
  ngs.transitions.archive                                                                                                                   
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.archive.from                                                                                                              
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.archive.from.0                                                                                                            
   workflows.workflow.editorial:type_setti   Validatable   Regex:                                                                           
  ngs.transitions.archive.label                              pattern: '/([^\PC])/u'                                                         
                                                             match: false                                                                   
                                                             message: 'Labels are not allowed to span multiple lines or contain control     
                                                           characters.'                                                                     
                                                           ↣ PrimitiveType: {  }                                                            
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.archive.to                                                                                                                
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.archive.weight                                                                                                            
   workflows.workflow.editorial:type_setti   Validatable   ValidKeys: '<infer>'                                                             
  ngs.transitions.archived_draft                                                                                                            
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.archived_draft.from                                                                                                       
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.archived_draft.from.0                                                                                                     
   workflows.workflow.editorial:type_setti   Validatable   Regex:                                                                           
  ngs.transitions.archived_draft.label                       pattern: '/([^\PC])/u'                                                         
                                                             match: false                                                                   
                                                             message: 'Labels are not allowed to span multiple lines or contain control     
                                                           characters.'                                                                     
                                                           ↣ PrimitiveType: {  }                                                            
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.archived_draft.to                                                                                                         
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.archived_draft.weight                                                                                                     
   workflows.workflow.editorial:type_setti   Validatable   ValidKeys: '<infer>'                                                             
  ngs.transitions.archived_published                                                                                                        
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.archived_published.from                                                                                                   
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.archived_published.from.                                                                                                  
  0                                                                                                                                         
   workflows.workflow.editorial:type_setti   Validatable   Regex:                                                                           
  ngs.transitions.archived_published.label                   pattern: '/([^\PC])/u'                                                         
                                                             match: false                                                                   
                                                             message: 'Labels are not allowed to span multiple lines or contain control     
                                                           characters.'                                                                     
                                                           ↣ PrimitiveType: {  }                                                            
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.archived_published.to                                                                                                     
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.archived_published.weigh                                                                                                  
  t                                                                                                                                         
   workflows.workflow.editorial:type_setti   Validatable   ValidKeys: '<infer>'                                                             
  ngs.transitions.create_new_draft                                                                                                          
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.create_new_draft.from                                                                                                     
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.create_new_draft.from.0                                                                                                   
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.create_new_draft.from.1                                                                                                   
   workflows.workflow.editorial:type_setti   Validatable   Regex:                                                                           
  ngs.transitions.create_new_draft.label                     pattern: '/([^\PC])/u'                                                         
                                                             match: false                                                                   
                                                             message: 'Labels are not allowed to span multiple lines or contain control     
                                                           characters.'                                                                     
                                                           ↣ PrimitiveType: {  }                                                            
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.create_new_draft.to                                                                                                       
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.create_new_draft.weight                                                                                                   
   workflows.workflow.editorial:type_setti   Validatable   ValidKeys: '<infer>'                                                             
  ngs.transitions.publish                                                                                                                   
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.publish.from                                                                                                              
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.publish.from.0                                                                                                            
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.publish.from.1                                                                                                            
   workflows.workflow.editorial:type_setti   Validatable   Regex:                                                                           
  ngs.transitions.publish.label                              pattern: '/([^\PC])/u'                                                         
                                                             match: false                                                                   
                                                             message: 'Labels are not allowed to span multiple lines or contain control     
                                                           characters.'                                                                     
                                                           ↣ PrimitiveType: {  }                                                            
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.publish.to                                                                                                                
   workflows.workflow.editorial:type_setti   NOT           ❌ @todo Add validation constraints to ancestor type: workflows.transition       
  ngs.transitions.publish.weight                                                                                                            
   workflows.workflow.editorial:uuid         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 the Standard install profile + content_moderation
  5. vendor/bin/drush config:inspect --filter-keys=workflows.workflow.editorial --detail --list-constraints

Proposed resolution

  1. Add validation constraints.
  2. Mark FullyValidatable.

Remaining tasks

Review.

User interface changes

None.

API changes

TBD

Data model changes

None.

Release notes snippet

N/A

📌 Task
Status

Needs work

Version

11.0 🔥

Component
Workflows 

Last updated 16 days ago

Created by

🇦🇺Australia Sam152

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024