Problem/Motivation
Contact form entity is not yet fully validatable:
.vendor/bin/drush config:inspect --filter-keys=contact.form.feedback --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
-------------------------------------------------- --------- ------------- ------ ---------------------------------------------------------------------------------------------
contact.form.feedback Correct 87% ✅❓ ValidKeys: '<infer>'
contact.form.feedback: Correct Validatable ✅✅ ValidKeys: '<infer>'
contact.form.feedback:_core Correct Validatable ✅✅ ValidKeys:
- default_config_hash
contact.form.feedback:_core.default_config_hash Correct Validatable ✅✅ NotNull: { }
Regex: '/^[a-zA-Z0-9\-_]+$/'
Length: 43
↣ PrimitiveType: { }
contact.form.feedback:dependencies Correct Validatable ✅✅ ValidKeys: '<infer>'
contact.form.feedback:id Correct Validatable ✅✅ Length:
max: 32
↣ PrimitiveType: { }
↣ Regex:
pattern: '/^[a-z0-9_]+$/'
message: 'The %value machine name is not valid.'
contact.form.feedback:label Correct Validatable ✅✅ Regex:
pattern: '/([^\PC])/u'
match: false
message: 'Labels are not allowed to span multiple lines or contain control characters.'
NotBlank: { }
↣ PrimitiveType: { }
contact.form.feedback:langcode Correct Validatable ✅✅ NotNull: { }
Choice:
callback: 'Drupal\Core\TypedData\Plugin\DataType\LanguageReference::getAllValidLangcodes'↣ PrimitiveType: { }
contact.form.feedback:message Correct Validatable ✅✅ Regex:
pattern: '/([^\PC\x09\x0a\x0d])/u'
match: false
message: 'Text is not allowed to contain control characters, only visible characters.'↣ PrimitiveType: { }
contact.form.feedback:recipients Correct NOT ✅❓ ⚠️ @todo Add validation constraints to config entity type: contact.form.*
contact.form.feedback:recipients.0 Correct Validatable ✅✅ Email:
message: '%value is not a valid email address.'↣ PrimitiveType: { }
contact.form.feedback:redirect Correct NOT ✅❓ ⚠️ @todo Add validation constraints to config entity type: contact.form.*
contact.form.feedback:reply Correct Validatable ✅✅ Regex:
pattern: '/([^\PC\x09\x0a\x0d])/u'
match: false
message: 'Text is not allowed to contain control characters, only visible characters.'↣ PrimitiveType: { }
contact.form.feedback:status Correct Validatable ✅✅ ↣ PrimitiveType: { }
contact.form.feedback:uuid Correct Validatable ✅✅ Uuid: { }
↣ PrimitiveType: { }
contact.form.feedback:weight Correct Validatable ✅✅ Range:
min: -2147483648
max: 2147483647
FullyValidatable: null
↣ PrimitiveType: { }
-------------------------------------------------- --------- ------------- ------ ---------------------------------------------------------------------------------------------
Steps to reproduce
- Get a local git clone of Drupal core
11.x
. 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!)composer require drush/drush
vendor/bin/drush config:inspect --filter-keys=contact.form.feedback --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 #distributions-and-recipes
.
Remaining tasks
MR
User interface changes
None.
API changes
None.
Data model changes
More validation 🚀
Release notes snippet
None.