We're updating the issue view to help you get more done. 

Validator not found for @Size on non-parameterized Map/Collection properties

Description

Validation of a bean property looking like:

1 2 3 @NotNull @Size(min = 1) private Map prop;

Fails with exception (see below).
However changing property to

1 2 3 @NotNull @Size(min = 1) private Map<?,?> prop;

does validation fine.

Looks like there is an issue in org.hibernate.validator.internal.util.TypeHelper class isAssignable method which does not resolves parametrized maps correctly.
Not sure if the same applies to parametrized collections.

Exception stacktrace:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'javax.validation.constraints.Size' validating type 'java.util.Map'. Check configuration for 'eventData' at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.throwExceptionForNullValidator(ConstraintTree.java:227) at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.getConstraintValidatorNoUnwrapping(ConstraintTree.java:308) at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.getConstraintValidatorInstanceForAutomaticUnwrapping(ConstraintTree.java:242) at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.getInitializedConstraintValidator(ConstraintTree.java:163) at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:116) at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:87) at org.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:73) at org.hibernate.validator.internal.engine.ValidatorImpl.validateMetaConstraint(ValidatorImpl.java:616) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:581) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForSingleDefaultGroupElement(ValidatorImpl.java:527) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:495) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:460) at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:410) at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:207)

Environment

None

Status

Assignee

Guillaume Smet

Reporter

Konstantin Kulagin

Components

Fix versions

Affects versions

6.0.7.Final

Priority

Major