Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Putting constraint annotation on collection of Strings
PostPosted: Mon Apr 23, 2012 9:07 am 
Newbie

Joined: Mon Jun 18, 2007 5:10 am
Posts: 3
Hi there !

I have a simple class :
Code:
public class Foo {
    @NotNull @Email
    private String[] emails;
}


which cannot be validated due to following exception :
Code:
javax.validation.UnexpectedTypeException: No validator could be found for type: class java.lang.String[]
   at org.hibernate.validator.engine.ConstraintTree.verifyResolveWasUnique(ConstraintTree.java:383) ~[hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
   at org.hibernate.validator.engine.ConstraintTree.findMatchingValidatorClass(ConstraintTree.java:364) ~[hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
   at org.hibernate.validator.engine.ConstraintTree.getInitializedValidator(ConstraintTree.java:313) ~[hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
   at org.hibernate.validator.engine.ConstraintTree.validateConstraints(ConstraintTree.java:144) ~[hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
   at org.hibernate.validator.engine.ConstraintTree.validateConstraints(ConstraintTree.java:117) ~[hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
   at org.hibernate.validator.metadata.MetaConstraint.validateConstraint(MetaConstraint.java:84) ~[hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
   at org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:452) ~[hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
   at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:397) ~[hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
   at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:361) ~[hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
   at org.hibernate.validator.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:313) ~[hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
   at org.hibernate.validator.engine.ValidatorImpl.validate(ValidatorImpl.java:139) ~[hibernate-validator-4.2.0.Final.jar:4.2.0.Final]


Any hint/workaround regarding this issue ?

EDIT: I tried to encapsulate my String[] emails into a EmailWrapper[] emails with @Valid on emails and @Email on my EmailWrapper.address field, but it doesn't seem to solve anything (I encounter different problems which doesn't seem solvable in my POV)

Thanks in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.