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

Gunnar Morling (JIRA) noreply at atlassian.com
Sat Aug 6 03:42:03 EDT 2011


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