JSR 303 seeks to define a meta-data model and API for JavaBean validation. “This API is seen as a general extension to the JavaBeans object model, and as such is expected to be used as a core component in other specifications, such as JSF, JPA, and Bean Binding.”
A standardized validation API would be a great addition to the JDK. I’ve used a couple including Commons Validator and XWork’s bundled validation framework. These frameworks make life easier. However, like most things, there are no standards.
XWork’s implementation provides the ability to traverse the inheritance tree. It also allows for validation based on the context (method call). It comes with a number of validators, including stringlength, required, date. Validation can take place at field or non-field level. Fairly easy to use; I’ve only had issues when developing validation along with type-conversion for non-trivial objects. However, that is specific to web-based situations.
If the JSR will be based on XWork’s implementation, my major concern is the definition of a context. The previous definition of an aliasname does not exist in non-XWork specific implementations. Aliasname’s were simply the method name of an Action. This worked since Action execution methods were no-arg by convention. This concept will have to provide validation on method calls with arguments. By the nature of annotations, this will not be an issue. However, I am curious to see the XML-based solution. Last of all, I look forward to the ability to conditionally exclude validation based on the current context.