Cascading validation on list items is not invoked

Description

Trying to validate a POJO with nested collection that requires item validation

class TestTopLevel {
public List<@Valid TestDetails> data = new ArrayList<>();
}

class TestDetails {
@NotEmpty
public String large = "";
}

TestTopLevel topLevelValue = new TestTopLevel();
TestDetails details = new TestDetails();
topLevelValue.data = new ArrayList<>();
topLevelValue.data.add(details);

Both validateProperty and validateValue fail to validate the list items.

violations = validator.validateProperty(topLevelValue, "data");
violations = validator.validateValue(TestTopLevel.class, "data", topLevelValue);

It appears that the issue is in the validationContext.appliesTo( metaConstraint ) call.
metaConstraint is correctly pointing to the "large" property of the item in the list when it gets there.
However "validatedProperty" value at this point is "data" from the top level class.

@Override
public boolean appliesTo(MetaConstraint<?> metaConstraint) {
return Objects.equals( validatedProperty, getPropertyName( metaConstraint.getLocation() ) );
}

private boolean validateMetaConstraint(BaseBeanValidationContext<?> validationContext, ValueContext<?, Object> valueContext, Object parent, MetaConstraint<?> metaConstraint) {
BeanValueContext.ValueState<Object> originalValueState = valueContext.getCurrentValueState();
valueContext.appendNode( metaConstraint.getLocation() );
boolean success = true;

if ( isValidationRequired( validationContext, valueContext, metaConstraint ) ) {

The equals check fails and the validation of the item is skipped because isValidationRequired returns false.

Environment

None

Assignee

Unassigned

Reporter

Alex Fedotov

Labels

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Affects versions

Priority

Major
Configure