By bnjmnm on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
10.2.x
Introduced in version:
10.2.0
Issue links:
Description:
The Symfony Choice validation constraint is now available for use in Drupal core schemas. Like all config validation constraints, This can be used in any schema definition like
some_definition:
# whatever
constraints:
Choice:
# choice options go here. Refer to the Symfony docs for
# all available options. This example uses 'callback'.
callback: 'Drupal\Some\Callback\Class::getThoseOptions'
something_else
type: string
constraints:
# Only two possible values are accepted.
Choice:
- un
- all
And this will enforce the config having a value exists within the value returned by the Choice: callback or choices option (the latter is the default option, so it is possible to omit that key).
Impacts:
Module developers