annotation-based validation framework [closed]
I'm looking for an annotation-based validation framework, that would allow me to validate parameter values. Somet开发者_StackOverflow中文版hing like the following:
void someMethod(@NotBlank String foo, @NotEmpty Collection bar, @Positive Integer baz, @NotNull Object obj) {
}
Validation of the parameters should happen automatically whenever an annotated method/constructor is called, so that there no way to bypass the validation.
If I could customise the error messages produced that would be nice. I'm using Java 1.5.
Try taking a look at OVal and others implementors of the JSR-303 (aka Bean validation)
That's a job for a JSR 303 - Bean Validation implementation, like Hibernate Validator (the RI). Check the various Bean Validation blog posts from Emmanuel Bernard (the spec lead).
精彩评论