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

validator.validateValue not working for wrapped values

Description

The error can simply be reproduced by using JavaFX properties. Here are some code snippets to reproduce the error:

Model:

1 2 3 public class TestModel { private Property<@Size(max = 5) String> id = new SimpleStringProperty(); }

Calling validator.validateValue(TestModel.class, "id", "123456789"); will end in the following RTE:

1 2 3 4 5 6 7 8 9 10 11 12 13 _Exception in thread "main" javax.validation.ValidationException: HV000221: An error occurred while extracting values in value extractor org.hibernate.validator.internal.engine.valueextraction.ObservableValueValueExtractor. at org.hibernate.validator.internal.engine.valueextraction.ValueExtractorHelper.extractValues(ValueExtractorHelper.java:47) at org.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:103) at org.hibernate.validator.internal.engine.ValidatorImpl.validateMetaConstraint(ValidatorImpl.java:569) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForSingleDefaultGroupElement(ValidatorImpl.java:527) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:496) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:461) at org.hibernate.validator.internal.engine.ValidatorImpl.validateValueInContext(ValidatorImpl.java:815) at org.hibernate.validator.internal.engine.ValidatorImpl.validateValue(ValidatorImpl.java:240) at org.hibernate.demos.validation.javafx.test.ValidateValue.main(ValidateValue.java:15) Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to javafx.beans.value.ObservableValue at org.hibernate.validator.internal.engine.valueextraction.ObservableValueValueExtractor.extractValues(ObservableValueValueExtractor.java:20) at org.hibernate.validator.internal.engine.valueextraction.ValueExtractorHelper.extractValues(ValueExtractorHelper.java:41)_

It looks like the extractValues method of ObservableValueValueExtractor can not be called since this needs a ObservableValue as parameter but Hibernate validator unwraps the value already earlier and passes the internal value (in this sample the id String) to the method instead of the property.

Environment

None

Status

Assignee

Unassigned

Reporter

Hendrik Ebbers

Labels

None

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Affects versions

6.0.13.Final

Priority

Major