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

Gunnar Morling (JIRA) noreply at atlassian.com
Mon Sep 26 17:08:35 EDT 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/BVAL-237?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43707#comment-43707 ] 

Gunnar Morling commented on BVAL-237:
-------------------------------------

First of all cross-field validation. Using the parent bean in error messages would be another use case.

> Expose validated bean via ConstraintValidatorContext
> ----------------------------------------------------
>
>                 Key: BVAL-237
>                 URL: http://opensource.atlassian.com/projects/hibernate/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