- Issue created by @borisson_
- First commit to issue fork.
- last update
about 1 year ago 30,391 pass, 4 fail - @eli-t opened merge request.
- Status changed to Needs review
about 1 year ago 6:42pm 21 October 2023 - last update
about 1 year ago 30,426 pass - π§πͺBelgium borisson_ Mechelen, π§πͺ
This needs a review from one of the user.module maintainers, tagging it like that, but this change is great. Thanks @Eli-T!
- πΈπ°Slovakia poker10
What if a site altered these settings already (or if using a module which is altering these)? Is this a BC break? The same applies for all other issues where we are hardcoding values (dblog, olivero, ...). I think we should consider this very carefully.
- πΊπΈUnited States moshe weitzman Boston, MA
LGTM. I think this needs input from config validation maintainers as well (leaving tag in for this).
- Status changed to RTBC
about 1 year ago 11:51am 2 November 2023 - last update
about 1 year ago 30,483 pass - πΈπ°Slovakia poker10
it's up to that module to then alter the validation constraints in the config schema.
So is there a draft change record/release notes snippet for all these "Add validation constraints to ..." changes somewhere?
- Status changed to Needs review
about 1 year ago 12:15pm 2 November 2023 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
@poker10: Please note that NOTHING in Drupal core or contrib is strictly validating config yet β only tests are, but contrib modules have no effect on that.
Change record: https://www.drupal.org/node/3362879 β . I've just updated it to document this, because you're right, that was missing: https://www.drupal.org/node/3362879/revisions/view/13198950/13294591 β
That made me realize that in this particular example, it may be better to follow the example set by β¨ Add a `langcode` data type to config schema Fixed , which did:
constraints: Choice: callback: 'Drupal\Core\TypedData\Plugin\DataType\LanguageReference::getAllValidLangcodes'
Because in this case, we could say that all valid values for
cancel_method
arearray_keys(user_cancel_methods()
.
(All of this would have been trivial if these were plugin IDs because for that we have thePluginExists
validation constraint, but the user cancelation methods system predates the plugin system!)That way, there is no need for altering the config schema anymore! π
- Status changed to Needs work
about 1 year ago 7:07am 3 November 2023 - π§πͺBelgium borisson_ Mechelen, π§πͺ
I agree that this makes more sense. The idea that alex mentioned at drupalcon Lille, was that config could be validatable without having drupal running will be more difficult with this change, but since we already have that example in the langcode data type that shouldn't hold this back.
- π§πͺBelgium borisson_ Mechelen, π§πͺ
It's not possible to define a callback like this, so we would have create a new function just to define this callback? I'm not sure that makes sens to do.
callback: 'array_keys(user_cancel_methods)'
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
#13:
config could be validatable without having drupal running will be more difficult with this change
That is already the case for any configuration that is configuring e.g. plugins: only the Drupal site itself can only ever know which plugins are in fact installed π
#14: correct, what you describe there is not yet possible. Well, technically it is, because closures are allowed β see https://symfony.com/doc/current/reference/constraints/Choice.html#supply.... But β¦ PHP closures cannot be defined in YAML files π
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
ACTUALLY! I just discovered https://symfony.com/doc/current/reference/constraints/Expression.html. Combine that with https://stackoverflow.com/questions/50782963/symfony-expression-validation and we should be able to do exactly what you wrote in #14, @borisson_!
I think this would be worth opening a blocking issue for? OTOH this would be the first use in core (because
\Drupal\Core\TypedData\Plugin\DataType\LanguageReference::getAllValidLangcodes()
actually is quite a bit more complex), so maybe this would be the appropriate issue? - π§πͺBelgium borisson_ Mechelen, π§πͺ
O wow, that is great, this is a perfect usecase for that. I think we can add it in this issue, that would get the example next to the implementation.
- π§πͺBelgium borisson_ Mechelen, π§πͺ
To use this, we would also need
symfony/expression-language
, that feels like it would be something we need to do in another issue (and we'd need to do dependency evaluation for it as well).I'm not sure if that is something we'd want to do; would there be other places where we could use expression language as well? What do you all think?
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
But this issue is the one that justifies that addition. I think we should add that dependency here, and add the dependency evaluation to the issue summary.
This would mean a massive DX improvement for making a lot of config validatable! π€©
Let's first prove that this works by implementing it and then worry about adding a dependency evaluation? π€ Tentatively tagging π
- πΊπΈUnited States DamienMcKenna NH, USA
What is left to do on this issue?