[AI Bundle][Platform] Make the structured output validation groups configurable - #2527
Open
marco-jouwweb wants to merge 1 commit into
Open
marco-jouwweb wants to merge 1 commit into
marco-jouwweb wants to merge 1 commit into
Conversation
marco-jouwweb
requested review from
OskarStark and
chr-hertel
as code owners
September 14, 2026 11:37
…nfigurable `ValidatorSubscriber` always validated the populated structured output object in the `Default` validation group, which collides with domain objects that already carry `Default` constraints for other purposes. Add an optional `groups` argument to `ValidatorSubscriber`, passed through `ValidatorResultConverter` to the buffered validation call and to `PartialObjectStreamListener` for the final object of a streamed result. A `validation_groups` invocation option overrides them for a single call; the subscriber consumes it so it is never forwarded to the provider. The AI Bundle exposes the default as `ai.structured_output.validation_groups`.
marco-jouwweb
force-pushed
the
platform-validator-subscriber-groups
branch
from
September 14, 2026 11:45
c28d82f to
0dbe637
Compare
marco-jouwweb
commented
Sep 14, 2026
| private string|GroupSequence|array|null $invocationGroups = null; | ||
|
|
||
| /** | ||
| * @param string|GroupSequence|array<string|GroupSequence>|null $groups The validation groups to validate the structured output in unless the "validation_groups" option is passed, or null for the validator's default group |
Contributor
Author
There was a problem hiding this comment.
Not very happy with this union type.. WDYT?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ValidatorSubscriberalways validates the populated structured output object in theDefaultvalidation group. When the target class is an existing domain object that already carriesDefaultconstraints for other purposes (forms, API input), the only ways out are decorating the subscriber or moving every existing constraint to custom groups. As discussed with @chr-hertel on Slack, this PR makes the groups configurable instead.Platform
ValidatorSubscribergets an optionalgroupsargument accepting the same values asValidatorInterface::validate()(a group name, a list of groups, or aGroupSequence). It is passed throughValidatorResultConverterto the buffered validation call and toPartialObjectStreamListener::setValidator(), so the final object of a streamed structured output is validated in the same groups.A single call can override them with the
validation_groupsoption. LikePlatformSubscriberdoes forresponse_format, the subscriber consumes the option onInvocationEventso it is never merged into the provider request, and applies it onResultEvent:AI Bundle
New
structured_output.validation_groupsoption, applied to theai.platform.structured_output.validator_subscriberservice as the default groups. It is a top-level node (not underplatform, whose children are the bridge types). An empty list keeps the current behavior; configuring groups whilesymfony/validatoris missing throws the same kind of "requires package" exception as the other optional integrations.Notes
nullkeeps validating in the validator's default group.ValidatorConstraintsDescriberstill describes constraints of every group in the generated JSON schema.🤖 Generated with Claude Code