[
http://opensource.atlassian.com/projects/hibernate/browse/HV-292?page=com...
]
Gunnar Morling updated HV-292:
------------------------------
Attachment: HV-292.diff
Initial patch for HV-292.
The annotation now has an additional parameter, "alias", which allows to set the
name, under which the evaluated object should be put into the script context.
I decided to concentrate on a solution for JSR 223 compatible languages for now. Using the
constraint with other languages should be fairly easy though by registering other
validators, e.g. for Spring EL.
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: Gunnar Morling
Fix For: 4.1.0
Attachments: 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...
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira