[hibernate-issues] [Hibernate-JIRA] Commented: (HV-292) Provide a constraint annotation @ScriptAssert

Hardy Ferentschik (JIRA) noreply at atlassian.com
Tue Apr 20 11:30:20 EDT 2010


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

Hardy Ferentschik commented on HV-292:
--------------------------------------

Applied Gunnar's ScriptAssert annotation

> Provide a constraint annotation @ScriptAssert
> ---------------------------------------------
>
>                 Key: HV-292
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-292
>             Project: Hibernate Validator
>          Issue Type: New Feature
>          Components: validators
>    Affects Versions: 4.1.0.Beta1
>            Reporter: Gunnar Morling
>            Assignee: Hardy Ferentschik
>             Fix For: 4.1.0
>
>         Attachments: HV-292-doc.diff, HV-292.diff
>
>
> Quite often the validation of one bean property depends on the value of another property of the same bean. In such case a custom class-level constraint and a corresponding validator have to be implemented.
> This effort can be reduced by providing a generic class-level constraint, which allows to evaluate arbitrary script expressions based on the annotated class as in the following example:
> @ScriptAssert(lang = "groovy", script = "_this.startDate.before(_this.endDate)")
> public class CalendarEvent {
>     private Date startDate;
>     private Date endDate;
>     //...
> }
> The blog post http://musingsofaprogrammingaddict.blogspot.com/2009/08/script-annotation-for-bean-validation.html describes, how such a constraint could be realized using the JSR 223 ("Scripting for the Java Platform") API.
> In alternative to solely rely on JSR 223 it should be investigated, whether a more general approach could be taken to enable the integration of scripting/expression languages, for which no JSR 223 binding exists (e.g. Spring EL). This could be realized by providing a SPI mechanism, which allows to plug-in additional script engine providers.

-- 
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