-->
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: multiple messages from single custom validator
PostPosted: Thu May 28, 2009 7:07 pm 
Newbie

Joined: Wed Sep 27, 2006 6:10 pm
Posts: 8
is it possible to define what message to be returned from a custom validator?

in my code, i have to do between 5 and 10 various checks on a field before its considered valid. is it possible to have in my isvalid routine a way where if a particular check in a series fails it can change the error message to indicate exactly what check failed? i tried to override the message method but that didn't work, it simply returned the default message every time.

my next step is to write a validator for each of the checks, but it would be nice if i can roll them up into one.


Top
 Profile  
 
 Post subject: Re: multiple messages from single custom validator
PostPosted: Thu May 28, 2009 7:28 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Which version of Hibernate Validator are you talking about. It is possible with the latest version 4.x of Validator which is based on Bean Validation.
There you get passed a so called ConstraintValidatorContext into ConstraintValidator.isValid. ConstraintValidatorContext has several methods to customize your error messages. Amongst it the possibility to add several error messages.

I recommend you have a look at this version of Hibernate Validator and also the JSR 303 (Bean Validation) specification.

--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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.