Improve config validation and use #config_target for settings form
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3580910. --> Reported by: [svendecabooter](https://www.drupal.org/user/35369) Related to !107 >>> <p>[Tracker]<br> <strong>Update Summary: </strong>`ai_context.settings` config validation<br> <strong>Check-in Date: </strong>MM/DD/YYYY<br> <strong>Blocked by: </strong>[#XXXXXX] (New issues on new lines)<br> <strong>Additional Collaborators: </strong> @username1, @username2<br> <em>Metadata is used by the <a href="https://www.drupalstarforge.ai/" title="AI Tracker">AI Tracker.</a> Docs and additional fields <a href="https://www.drupalstarforge.ai/ai-dashboard/docs" title="AI Issue Tracker Documentation">here</a>.</em><br> [/Tracker]</p> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>AiContextSettingsForm uses #default_value with manual $config-&gt;get() calls and a manual submitForm() that sets each config value individually. Validation for numeric fields (max_global_items, max_items, max_tokens) is done only via #min/#max attributes &mdash; there is no schema validation. The provider_config mapping duplicates the structure of ai.provider_config inline rather than reusing the standardized schema type.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>1. Add FullyValidatable: ~ constraint at the ai_context.settings config_object level.<br> 2. Add Range constraints on max_items (1&ndash;10), max_global_items (0&ndash;10), and max_tokens (min 100) in the schema.<br> 3. Add NotBlank constraint on context_prefix.<br> 4. Replace the inline provider_config mapping with type: ai.provider_config.<br> 5. Replace all #default_value usages with #config_target in the form.<br> 6. Remove the manual submitForm() config saves and resolveProviderValue() method &mdash; let ConfigFormBase handle saving via #config_target.<br> 7. Replace getEditableConfigNames() with RedundantEditableConfigNamesTrait.</p> <h3 id="summary-remaining-tasks">Remaining tasks</h3> <p>- Implement the schema and form changes.<br> - Test that form submission, validation, and config overrides work correctly.</p> <h3 id="summary-ai-usage">AI usage (if applicable)</h3> <p>[x] AI Assisted Issue<br> This issue was generated with AI assistance, but was reviewed and refined by the creator.</p> <p>[x] AI Assisted Code<br> This code was mainly generated by a human, with AI autocompleting or parts AI generated, but under full human supervision.</p> > Related issue: [Issue #3580935](https://www.drupal.org/node/3580935) > Related issue: [Issue #3580948](https://www.drupal.org/node/3580948)
issue