[hibernate-issues] [Hibernate-JIRA] Commented: (BVAL-237) Expose validated bean via ConstraintValidatorContext

Hardy Ferentschik (JIRA) noreply at atlassian.com
Tue Feb 28 05:07:57 EST 2012


    [ https://hibernate.onjira.com/browse/BVAL-237?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45723#comment-45723 ] 

Hardy Ferentschik commented on BVAL-237:
----------------------------------------

I see that as a very useful feature as well

{quote}
What use case do you see?
It is related to BVAL-240 (cross field validation), do you have any other use case?
{quote}

Another usecase is to generate customized error messages. If you know the property you are evaluating you can incorporate this into the error message (in a generic way).

{quote}
My main problem with that is leakage. Forget validateValue, forget reliable validate based on changesets.
{quote}

I don't understand what you mean with that.
 

> Expose validated bean via ConstraintValidatorContext
> ----------------------------------------------------
>
>                 Key: BVAL-237
>                 URL: https://hibernate.onjira.com/browse/BVAL-237
>             Project: Bean Validation
>          Issue Type: New Feature
>          Components: spec-general
>    Affects Versions: 1.0 final
>            Reporter: Gunnar Morling
>             Fix For: 1.1
>
>
> In the feedback forum a user [suggested|https://forum.hibernate.org/viewtopic.php?f=26&t=1012111] to expose the currently validated bean via {{javax.validation.ConstraintValidatorContext}}. 
> IMO that's a good addition as it would people allow to create custom cross-field constraints more easily. I'm not sure whether access should be restricted to the current leaf bean or whether also the root bean should be accessible. In the latter case some methods from {{ConstraintViolation}} might just be offered on {{ConstraintValidatorContext}} as well:
> {code:java}
> getConstraintDescriptor()
> getLeafBean()
> getPropertyPath()
> getRootBean()
> getRootBeanClass() 
> {code}
> Another idea would be to have an {{unwrap()}} method on {{ConstraintValidatorContext}} which would allow for BV providers to expose additional functionality. WDYT?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list