-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: validator.getPotentialInvalidValues("user.username"
PostPosted: Tue Jul 17, 2007 6:18 am 
Beginner
Beginner

Joined: Tue Jul 03, 2007 11:36 am
Posts: 24
How to easily validate the username below. I got the annotated vo. But it is in the jsf loginBean. How to validate the user.username property only.

clazz = Class.forName(com.abc.LoginBean);

ClassValidator validator = new ClassValidator(clazz);

InvalidValue[] validationMessages = validator.getPotentialInvalidValues("user.username", value);


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 17, 2007 3:19 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Seems to be alright

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 17, 2007 11:02 pm 
Beginner
Beginner

Joined: Tue Jul 03, 2007 11:36 am
Posts: 24
I have tried. It did not work. No error and validation also.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 18, 2007 1:27 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Check http://www.hibernate.org/hib_docs/validator/reference/en/html_single/#d0e436 and the unit test site. They contain working example.
Without more details, there is no way to tell what's wrong.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 19, 2007 2:40 am 
Beginner
Beginner

Joined: Tue Jul 03, 2007 11:36 am
Posts: 24
Here is my code.
Code:
public class LoginBean {
   private User user;
。。。。。。
}

public class User {
    @org.hibernate.validator.Email
     private String email;
。。。
}

   Class   clazz = Class.forName("com.abc.LoginBean");   
   ClassValidator validator = new ClassValidator(clazz);
      
   InvalidValue[] validationMessages = validator.getPotentialInvalidValues("user.email", "wrongemail");

Is it because of @valid? It just mentioned for collection in the documentation, how about it is one to one relationship like Loginbean to User?

I have checked the seam validation tag source code. It does not use user.email as the parameter for ...invalidvalues(). It only use email as property name and create the validator for User class.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 19, 2007 9:35 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Yes you need to add @Valid. Are you sure the ref doc mention only @Valid for collections? If true, please open a JIRA issue, this needs to be improved.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 23, 2007 10:14 pm 
Beginner
Beginner

Joined: Tue Jul 03, 2007 11:36 am
Posts: 24
Quote:
perform validation recursively
on the associated
object. If the object
is a Collection or an array,
the elements are validated
recursively. If the
object is a Map, the value
elements are validated recursively.


This is inside the document. For my understanding, the @valid is for the addressValidator.getInvalidValues(address); to tell hibernate whether want to validate the associated object. Since my code is explicitly tell hibernate to validate the property of associated object. So, it should not use @valid right?

I have tried @valid for user object. Did not work also.
What should i do now????


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 25, 2007 1:27 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
yes you should I guess, because a @Valid property could also be @NotNull or @Size for example

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 26, 2007 1:18 am 
Beginner
Beginner

Joined: Tue Jul 03, 2007 11:36 am
Posts: 24
I do not understand. I have tested with @valid with my example.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 26, 2007 1:46 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
We don't understand each other it seems. Write a minimal but complete reproducible test case that shows what you expect and what you think is wrong and post it here. That will help

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

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.