[hibernate-issues] [Hibernate-JIRA] Commented: (HV-388) Support property level ScriptAssert

Hardy Ferentschik (JIRA) noreply at atlassian.com
Fri Oct 22 07:42:48 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HV-388?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=38848#action_38848 ] 

Hardy Ferentschik commented on HV-388:
--------------------------------------

One possible solution could be to introduce some Hibernate Validator specific interface, eg {{ValueContextInjectable}}. Validator could check just before the {{isValid}} call whether the {{ConstraintValidator}} implements this interface and if so set the context. However, it bypasses the spirit of Bean Validation.

> Support property level ScriptAssert
> -----------------------------------
>
>                 Key: HV-388
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-388
>             Project: Hibernate Validator
>          Issue Type: New Feature
>          Components: engine
>    Affects Versions: 4.1.0.Final
>            Reporter: jason shi
>            Assignee: Hardy Ferentschik
>             Fix For: 4.2.0
>
>
> Current hibernate validator's ScriptAssert can only defined on the Class level, not property level.
> In OVal,it can define the ScriptAssert at the property level,eg:
> {code}
> public class BusinessObject 
> {
>   @NotNull
>   public String deliveryAddress;
>   @NotNull public String invoiceAddress;
>   // mailingAddress must either be the delivery address or the invoice address 
>   @Assert(expr = "_value ==_this.deliveryAddress || _value == _this.invoiceAddress", lang = "groovy")
>   public String mailingAddress;
> }
> {code}
> With property level,we can get following benefit:
> 1. Can be used in single property validation, It's very useful in UI layer validation
> 2. The validation rule is close to the property definition, it's easy to manage
> In JSR303 spec, the ValueContext is not passed to the Contrain Validator as a parameter,
> so the validator can't get the "Current Bean" of the current property to be validated.
> The validation engine need to some special work to support this feature.
> OVal can do this, so it won't be a problem for hibernate validator.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list