Problem/Motivation
Once #3364109: Configuration schema & required values: add test coverage for `nullable: true` validation support lands, MANY (most!) config schema data types will automatically get the NotNull validation constraint.
But … that still is not sufficient validation.
Steps to reproduce
With Config Inspector's latest release, #3364109: Configuration schema & required values: add test coverage for `nullable: true` validation support will show:
$ vendor/bin/drush config:inspect --filter-keys system.date --detail --strict-validation --list-constraints
Legend for Data:
✅❓ → Correct primitive type, detailed validation impossible.
✅✅ → Correct primitive type, passed all validation constraints.
----------------------------------------- --------- ------------- ------ ------------------------------
Key Status Validatable Data Validation constraints
----------------------------------------- --------- ------------- ------ ------------------------------
system.date Correct 100% ✅✅ ValidKeys: '<infer>'
↣ NotNull: { }
system.date: Correct Validatable ✅✅ ValidKeys: '<infer>'
↣ NotNull: { }
system.date:_core Correct Validatable ✅✅ ValidKeys:
- default_config_hash
↣ NotNull: { }
system.date:_core.default_config_hash Correct Validatable ✅✅ NotNull: { }
Regex: '/^[a-zA-Z0-9\-_]+$/'
Length: 43
↣ PrimitiveType: { }
system.date:country Correct Validatable ✅✅ ValidKeys: '<infer>'
↣ NotNull: { }
system.date:country.default Correct Validatable ✅✅ ↣ PrimitiveType: { }
↣ NotNull: { }
system.date:first_day Correct Validatable ✅✅ ↣ PrimitiveType: { }
↣ NotNull: { }
system.date:timezone Correct Validatable ✅✅ ValidKeys: '<infer>'
↣ NotNull: { }
system.date:timezone.default Correct Validatable ✅✅ ↣ PrimitiveType: { }
↣ NotNull: { }
system.date:timezone.user Correct Validatable ✅✅ ValidKeys: '<infer>'
↣ NotNull: { }
system.date:timezone.user.configurable Correct Validatable ✅✅ ↣ PrimitiveType: { }
↣ NotNull: { }
system.date:timezone.user.default Correct Validatable ✅✅ ↣ PrimitiveType: { }
↣ NotNull: { }
system.date:timezone.user.warn Correct Validatable ✅✅ ↣ PrimitiveType: { }
↣ NotNull: { }
----------------------------------------- --------- ------------- ------ ------------------------------
This is invalid.
Proposed resolution
Require more than PrimitiveType AND more than NotNull! That should lead to:
$ vendor/bin/drush config:inspect --filter-keys system.date --detail --strict-validation --list-constraints
Legend for Data:
✅❓ → Correct primitive type, detailed validation impossible.
✅✅ → Correct primitive type, passed all validation constraints.
----------------------------------------- --------- ------------- ------ ------------------------------
Key Status Validatable Data Validation constraints
----------------------------------------- --------- ------------- ------ ------------------------------
system.date Correct 67% ✅❓ ValidKeys: '<infer>'
↣ NotNull: { }
system.date: Correct Validatable ✅✅ ValidKeys: '<infer>'
↣ NotNull: { }
system.date:_core Correct Validatable ✅✅ ValidKeys:
- default_config_hash
↣ NotNull: { }
system.date:_core.default_config_hash Correct Validatable ✅✅ NotNull: { }
Regex: '/^[a-zA-Z0-9\-_]+$/'
Length: 43
↣ PrimitiveType: { }
system.date:country Correct Validatable ✅✅ ValidKeys: '<infer>'
↣ NotNull: { }
system.date:country.default Correct NOT ✅❓
system.date:first_day Correct NOT ✅❓
system.date:timezone Correct Validatable ✅✅ ValidKeys: '<infer>'
↣ NotNull: { }
system.date:timezone.default Correct NOT ✅❓
system.date:timezone.user Correct Validatable ✅✅ ValidKeys: '<infer>'
↣ NotNull: { }
system.date:timezone.user.configurable Correct Validatable ✅✅ ↣ PrimitiveType: { }
↣ NotNull: { }
system.date:timezone.user.default Correct NOT ✅❓
system.date:timezone.user.warn Correct Validatable ✅✅ ↣ PrimitiveType: { }
↣ NotNull: { }
----------------------------------------- --------- ------------- ------ ------------------------------
Remaining tasks
TBD
User interface changes
None.
API changes
None.
Data model changes
None.
Comments
Comment #2
wim leersComment #3
wim leersTested again, and verified that #3364108: Configuration schema & required keys does not need yet another addition 👍
Comment #5
wim leers