[Validator] Allow Nested Valid Constraint #49117
Closed
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.
Removes the restriction that the
Valid
constraint cannot be nested inside aComposite
constraint.My use case is attempting naively to use
Valid
with aWhen
constraint, like so...ie. Only descend to validate this property when some condition is met, in my case when another boolean field is true.
This functionality seems to have been added some time ago and while I can see other constraints have been added with the same restriction, I can't see the precise reason so I'm hoping something has changed in the meantime. A warning sign is that the
groups
property is not defined on theValid
constraint when used this way, hence the addition of the default. Any pointers appreciated.Apologies if this case has been brought up before but I couldn't find an issue, or if there is a workaround or better approach. I'll hold on updating tests until this can be verified or rejected.