|
|
|
Change By:
|
Hardy Ferentschik
(12/Jul/13 1:28 AM)
|
Description:
|
Hi,
I have a list of String in my bean :
These strings are email and i want to validate them.
So, i did in my bean :
{code}
@NotEmpty
@Email
//@Valid <= uncommenting that line doesnot change anything.
List<String> emails ;
{code}
At execution, i've got the error :
{noformat}
Exception in thread "main" javax.validation.UnexpectedTypeException: No validator could be found for type: java.util.List<java.lang.String>
at org.hibernate.validator.engine.ConstraintTree.verifyResolveWasUnique(ConstraintTree.java:236)
at org.hibernate.validator.engine.ConstraintTree.findMatchingValidatorClass(ConstraintTree.java:219)
at org.hibernate.validator.engine.ConstraintTree.getInitializedValidator(ConstraintTree.java:167)
at org.hibernate.validator.engine.ConstraintTree.validateConstraints(ConstraintTree.java:113)
at org.hibernate.validator.metadata.MetaConstraint.validateConstraint(MetaConstraint.java:121)
at org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:334)
at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForRedefinedDefaultGroup(ValidatorImpl.java:278)
at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:260)
at org.hibernate.validator.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:213)
at org.hibernate.validator.engine.ValidatorImpl.validate(ValidatorImpl.java:119)
at com.adeuza.movalys.validation.hibernate.TestMain.main(TestMain.java:75)
{noformat}
I don't know if it is a bug in hibernate validator. I have looked at the JSR303 and i have not seen anything
about List of primitives. You can validate per example
List
_List
<Person>
_
with
_
@
Valid
Valid_
and it works well because
the validator knows about Person class.
I have used a little the Oval framework and with it, you can tell if the check applies to the container,
or the values inside, or the keys(for map). I don't know if you can do that with JSR303.
I'm interesting with your point of view.
|
|
|
|