-->
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.  [ 3 posts ] 
Author Message
 Post subject: Validation Customizing property path in error messages
PostPosted: Thu Mar 31, 2011 11:07 am 
Newbie

Joined: Mon Dec 15, 2008 2:28 pm
Posts: 8
Hello,
Is it possible to customize the error messages for inbuilt constraints such as @Range?

For example instead of seeing the error message:
foo[0].bar[2].value must be between 0 and 999

can I instead somehow see the error message:
fooName.barName.value must be between 0 and 999

where fooName and barName are string representations of some sort for the objects foo[0] and bar[2]?

Obviously I don't want to reimplement @Range as a custom validation constraint and then supply the message template. I want to use the inbuilt implementation of @Range, but just customize the property path to be more (my) user friendly.

Thanks!

_________________
Naresh
Please rate replies if they've helped you out.


Top
 Profile  
 
 Post subject: Re: Validation Customizing property path in error messages
PostPosted: Fri Apr 01, 2011 2:46 am 
Hibernate Team
Hibernate Team

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

foo[0].bar[2].value[i] looks like the property path of the constraint violation. The path is normally not part of the default error message. Are you using JSF? Or some other custom [i]MessageInterpolator? Maybe you can some code on how you use @Range?

--hardy


Top
 Profile  
 
 Post subject: Re: Validation Customizing property path in error messages
PostPosted: Fri Apr 01, 2011 10:15 am 
Newbie

Joined: Mon Dec 15, 2008 2:28 pm
Posts: 8
Doh! You are right. I am adding the property path in the Aspect class that is executing the Validator.validate. When I get validation errors I add the property path to the violation's original message.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.