[Validator] Add support for automatically sequencing constraints #45716
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.
I realized that I sequence 99% of my constraints when I use the validator component because it's more performant, prevents unexpected exceptions and allows to have less violations at a time. I'd love an opt-in mode where all the constraints would be sequenced automatically, to avoid writing endless cascades of the
Sequentially
constraint. It's especially useful when using theCollection
constraint on an array for example.Before:
After:
Decorating the metadata directly could work but it would require way more changes in the code.