Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

annotation-based validation framework [closed]

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.

like image 805
Dónal Avatar asked Sep 10 '10 07:09

Dónal


2 Answers

Try taking a look at OVal and others implementors of the JSR-303 (aka Bean validation)

like image 50
Riduidel Avatar answered Sep 27 '22 21:09

Riduidel


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).

like image 32
Pascal Thivent Avatar answered Sep 27 '22 23:09

Pascal Thivent