Skip to content

Include cross-parameter violations in hasErrors() and getAllErrors()#36672

Open
tianhaocui wants to merge 1 commit intospring-projects:mainfrom
tianhaocui:fix-cross-parameter-validation-errors
Open

Include cross-parameter violations in hasErrors() and getAllErrors()#36672
tianhaocui wants to merge 1 commit intospring-projects:mainfrom
tianhaocui:fix-cross-parameter-validation-errors

Conversation

@tianhaocui
Copy link
Copy Markdown

Closes #36666

MethodValidationResult.hasErrors() only checked getParameterValidationResults(), completely ignoring cross-parameter constraint violations. Similarly, getAllErrors() only collected errors from per-parameter results.

When adapt-constraint-violations is enabled, cross-parameter violations are stored separately via getCrossParameterValidationResults(). This caused hasErrors() to return false and getAllErrors() to return an empty list even when cross-parameter violations were present, effectively swallowing these errors.

Changes:

  • hasErrors() now also checks getCrossParameterValidationResults()
  • getAllErrors() now includes cross-parameter errors via Stream.concat

MethodValidationResult.hasErrors() only checked
getParameterValidationResults(), ignoring cross-parameter constraint
violations entirely. Similarly, getAllErrors() only collected errors
from per-parameter results.

When adapt-constraint-violations is enabled, cross-parameter violations
are stored separately via getCrossParameterValidationResults(). Both
hasErrors() and getAllErrors() now include these results so that
cross-parameter constraint violations are properly surfaced.

Closes spring-projects#36666

Signed-off-by: cuitianhao <54015884+tianhaocui@users.noreply.github.com>
@tianhaocui tianhaocui force-pushed the fix-cross-parameter-validation-errors branch from 6e239f0 to 7aca8be Compare April 19, 2026 09:51
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MethodValidationAdapter ignores cross-parameter violations when adapt-constraint-violations is enabled

2 participants