Problem/Motivation
Date AP Style's settings schema is present but not fully constrained, which prevents 100% config validation.
Drupal 10.2 introduced configuration validation constraints and #config_target so modules can strictly validate settings:
#3376195 Choice constraint for configuration schema,
#3373502 Using validation constraints via #config_target.
Steps to reproduce
- Install Date AP Style module
- Run
drush config:inspect date_ap_style.settings - Note configuration shows as validatable but without strict constraints
- Try setting invalid values like
drush config:set date_ap_style.settings separator "invalid" - Invalid values are accepted without validation errors
(Drush 13 will still allow setting invalid config, but a future version may enable config validation. )
Proposed resolution
- Add strict constraints to
config/schema/date_ap_style.schema.yml:- separator:
Choicewith explicit options (endash,to). - timezone:
ChoicewithcallbacktoDateTimeZone::listIdentifiers(as per Drupal core's system module pattern). - Add missing field formatter schema definitions for
timestamp_ap_styleanddaterange_ap_style. - Ensure schema defaults match
defaultConfiguration().
- separator:
- Refactor settings form to use
#config_targetfor each element so schema constraints are enforced automatically on submit. - Add comprehensive post-update function to:
- Migrate legacy configuration names and structure
- Convert string/integer boolean values to proper boolean types
- Fix entity view display field formatter settings data types
- Handle both fresh installations and existing sites
- Add tests:
- Kernel: Configuration validation with valid/invalid values.
- Functional: UI shows inline errors when submitting invalid inputs.
- Set/confirm minimum core version to 10.2+ (required for constraints +
#config_targetworkflow).
Remaining tasks
- [x] Add/adjust constraints in
date_ap_style.schema.yml(separator Choice, timezone Choice callback). - [x] Add missing field formatter schema definitions.
- [x] Update settings form elements to use
#config_target. - [x] Implement comprehensive
post_updatefunction to normalize existing config and handle data type conversions. - [x] Deprecate
date_ap_style.date_ap_style.dateapstylesettingsschema . - [x] Align schema defaults with
defaultConfiguration(). - [x] Write Kernel tests for invalid/valid config validation.
- [x] Ensure PHP strict types in all PHP files.
- [x] Write Functional tests for form validation.
- [x] Update composer.json to require core ≥10.2.
User interface changes
Simplified the default settings form by removing custom submit logic and leveraging #config_target for automatic configuration handling. Form validation now happens automatically through schema constraints.
API changes
Configuration schema now includes strict validation constraints. Sites using invalid configuration values will need to update them to valid options.
Data model changes
Boolean configuration values are now stored as proper boolean types instead of strings or integers. Legacy configurations are automatically migrated via post-update functions.
Release notes (when merged)
- Configuration is now strictly validated using schema constraints and
#config_target. - Boolean values in configuration are now properly typed (migrated automatically).
- Field formatter settings in entity view displays are automatically cleaned up.
- Sites on Drupal 10.0–10.1 must upgrade core to ≥10.2 before updating this module.
- Invalid timezone and separator values will now trigger validation errors.
Issue fork date_ap_style-3542751
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
Comment #2
trackleft2Comment #3
trackleft2Comment #5
trackleft2Comment #6
trackleft2On initial module install, this is what I see when I run the config_inspector module drush config:inspect command
And on an entity view display using the
timestamp_ap_styleformatter.And on the
daterange_ap_styleformatter.Then when I run the database updates I see:
Comment #7
trackleft2There are still some undone tasks.
Comment #8
trackleft2Comment #9
trackleft2Comment #10
trackleft2Comment #11
trackleft2Comment #12
trackleft2Comment #13
trackleft2Comment #14
trackleft2Comment #17
trackleft2Comment #19
trackleft2