Request for Expression Language (EL) for Validator annotations
--------------------------------------------------------------
Key: ANN-506
URL:
http://opensource.atlassian.com/projects/hibernate/browse/ANN-506
Project: Hibernate Annotations
Type: New Feature
Components: validator
Environment: All
Reporter: Chris Hansen
Since annotations are limited to primitive types, I would like to see a type of EL for the
Validator annotations (similar to the JSF/JSP EL). This would effectively overcome this
limitation of annotations and allow for very powerful functionality, such as utilizing the
natural ordering of classes. For example:
@Range(min="#{MyClass.MIN_OBJECT}", max="#{MyClass.MAX_OBJECT}")
public MyClass getCurrent()
Assuming MIN_OBJECT and MAX_OBJECT are (static, final) instances of MyClass and MyClass
implements Comparable<myClass>, the validator could compare the return value of the
method with both MIN_OBJECT and MAX_OBJECT and validate that it is within the desired
range.
This is just an example. I'm sure there are many more interesting uses possible
because this is a powerful concept.
The regular functionality of the annotatinos could be preserved by treating static
(non-EL) values, such as the string "0", as old-style primitives, e.g.
@Min(value="0").
--
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