-->
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.  [ 2 posts ] 
Author Message
 Post subject: How to get the InvalidValue Type
PostPosted: Thu Oct 09, 2008 10:31 pm 
Newbie

Joined: Thu Oct 09, 2008 10:10 pm
Posts: 1
After executing the validation on a bean using the ClassValidator and getting the array of InvalidValues. Other than the InvalidValue's message attribute is there any other attribute that may tell you which constrains failed on the bean? I need to be able to distinguish between the different constraints.


For example:
public class Test
{

@Max(value="45")
@NotEmpty
public int number;

@NotEmpty
public String data;
}

Having a Test instance with the following values

Test t = new Test();
t.number=34;
t.message="";

One of my business rules to discard an object is that the value on the number attribute is less than 45, how can I make sure that this rule was broken by the object above other than parsing the Invalid value message? And as you know these message can be customized so that means I cannot trust them.

thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 12, 2008 3:06 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

Maybe InvalidValue.getPropertyName() and InvalidValue.getPropertyPath() might be useful for you. Using these methods you can easily distinguish between constraint violations on data vs number. It would not help though in order to find out which of the two constraint on number failed.

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.