-->
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: Validator: Pass label names as a substitution in message
PostPosted: Mon Jan 11, 2010 8:37 pm 
Newbie

Joined: Mon Jan 11, 2010 7:41 pm
Posts: 1
Hi,
I am using Hibernate validator implementation of the Bean Validation spec (JSR303)
I have defined validators at the field level in a class.
This class is used in a different context and I want to show different message for different contexts

For example, I have Address class and it is reused as Business Address and Postal Address and it is required that messages have the label included as substitution like
"Postal email not valid" and
"Business email not valid"

in the resource bundle I have {fieldLable} email not valid
similarly for not nulls {fieldLabel} should not be null

not sure how to achieve that

Anyone ?

Thanks and Regards
Deepesh


Top
 Profile  
 
 Post subject: Re: Validator: Pass label names as a substitution in message
PostPosted: Tue Jan 12, 2010 9:54 am 
Hibernate Team
Hibernate Team

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

there are several ways of achieving this. Assuming you have a custom Address constraint, you could add an additional parameter to it, for example an addressType enum. Using this parameter in your custom ConstraintValidator implementation you could dynamically decide which message template to use depending on this parameter (see ConstraintValidatorContext.

--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.