Problem/Motivation

As a result of the change of the minimum supported core version to 10.3 in parent issue #3565209: [Meta] Drop support for Drupal 10.2 and below, it should now be possible to implement full validation of all of modules' configuration schema, introduced with change record: Stricter validation for config schema types is available, since version 10.3.0.

See the reports from Config Inspector:

Fix admin_toolbar.settings:


Fix validation of:

  • menu_depth integer value with a Range constraint from 1 to 9 with a not in range error message.
  • sticky_behavior string value with a Choice constraint with allowed values provided by an enum class callback.
  • timeout integer value with a Choice constraint with allowed values provided by a final class callback returning a range of integers with a step.

Fix admin_toolbar_tools.settings:


Fix validation of max_bundle_number integer value with a Range constraint from 1 to 500 with a not in range error message.

Steps to reproduce

Proposed resolution

Fix the reported schema validation errors by adding validation constraints and the FullyValidatable property.

Examples of similar issues:

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dydave created an issue. See original summary.

dydave’s picture

Quick follow-up on this issue:

All the changes detailed in the issue summary have been implemented and described in the merge request MR !205 above at #2.

See the resulting reports after applying the changes:

Fixed admin_toolbar.settings:

Fixed admin_toolbar_tools.settings:

Since all the tests and jobs still seem to be passing 🟢, moving issue to Needs review as an attempt to get more testing feedback and reviews.

These changes require Drupal core 10.3 or higher and should probably be merged after related:
#3569351: Drop support for Drupal 10.2 and below

Feel free to let us know if you have any comments, questions or concerns on any aspects of this issue or the suggested changes in the merge request, we would surely be glad to help.
Thanks in advance!

  • dydave committed 0d8bd7da on 3.x
    Issue #3570717 by dydave: Made configuration schema fully validatable.
    
dydave’s picture

Status: Needs review » Fixed

Merged, thanks!

The configuration schemas of the three modules are now fully validatable:

  • Admin Toolbar, Admin Toolbar Tools and Admin Toolbar Search: the settings schemas now have the FullyValidatable constraint, so all the properties are required and must be valid. Config labels were aligned with the settings forms.
  • Constraints:
    • Range constraints for menu_depth (1 to 9) and max_bundle_number (1 to 500), matching the limits of the forms.
    • Choice constraints for sticky_behavior and hoverintent_behavior.timeout, with the allowed values provided by new enums (AdminToolbarStickyBehavior and AdminToolbarHoverIntentTimeout) in Drupal\admin_toolbar\Enum.
  • Enums used in the code: the settings form and admin_toolbar.module now use the sticky behavior enum instead of raw strings.
  • Tools settings form: the show_local_tasks setting is only saved when the field is displayed, so it can no longer be overwritten with NULL.
  • Tests: new Kernel tests for the three schemas, built on a shared base class, check that:
    • all properties are required;
    • NULL values and wrong types are rejected;
    • out-of-range and invalid choice values are rejected;
    • the default install values are valid.

    Each test case asserts the exact expected validation errors. The .gitlab-ci.yml file was updated for the new tests.

All tests pass on the tested core versions.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.