- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
π Configuration schema & required values: add test coverage for `nullable: true` validation support Fixed has already implemented exactly this! ππ₯³
There are two different ways that a nullable property of a configuration type can be defined, one that uses a custom property name and custom code to evaluate it and one that uses the standard Symfony NotNull constraint.
The first approach uses a boolean 'nullable' property. Example:
# Schema for the entity reference 'default' selection handler settings.
entity_reference_selection.default:
type: entity_reference_selection
label: 'Default selection handler settings'
mapping:
target_bundles:
type: sequence
label: 'types'
nullable: true
This property is set if the item is optional; if not set, the item is required. If the 'nullable' property is used, validation is done on a custom basis in \Drupal\Core\Config\Schema\SchemaCheckTrait::checkValue()
.
Second, by adding NotNull to an array of constraints. Example:
system.site:
type: config_object
label: 'Site information'
mapping:
uuid:
type: uuid
label: 'Site UUID'
constraints:
Uuid: []
NotNull: []
If NotNull is used, the item is required, while if its absent it is presumed to be optional (though, in fact, is required because of the handling of 'nullable'). Validation for NotNull is done via a Symfony constraint.
Probably most consistent to standardize on NotNull constraint, but doing so would require changes to almost all configuration items, as the default (not nullable) would now require an explicit NotNull constraint.
Alternately, remove the NotNull constraint on UUID in system.site and, maybe, switch to applying NotNull constraint if 'nullable' property is empty in place of current custom validation code.
Closed: duplicate
11.0 π₯
Last updated
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
π Configuration schema & required values: add test coverage for `nullable: true` validation support Fixed has already implemented exactly this! ππ₯³