I'm looking for an annotation-based validation framework, that would allow me to validate parameter values. Something 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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With