Parameter validation does not stop when group in sequence has cascaded constraint violations.

Description

When validating method parameters where a groupsequence is in place, cascaded constraints do not cause the validator to halt after validating that group.

Given the following setup:

Validating method test of class TestImpl for group CompoundGroup with a CompoundEntity comprising of an Entity with both value1 and value 2 set to null, one would expect the following:

  • Validation be run for Group1

  • A ConstraintViolation to be given for Entity::value1

  • Validating halting after Group1 validation is complete because a constraint violation is given.

This behaviour is seen when validating said CompoundEntity directly, however the method validator does not bail if a group in the sequence raises a ConstraintViolation. See also attached test-case.

I noticed in ValidatorImpl::validateParametersInContext (line 1170 of 5.2.4-Final) only numberOfFailingConstraints is checked, rather than a construction similar to the validateInContext method that checks the amount of failing constraints of the context. This causes any constraint violations resulting from the validateCascadedConstraints call to be ignored.

If I can find some time this evening I will provide a pull request with the suggested fix.

Environment

None

Status

Assignee

Unassigned

Reporter

Jan-Willem Willebrands

Labels

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Affects versions

Priority

Major
Configure