开发者

annotation-based validation framework [closed]

开发者 https://www.devze.com 2023-01-16 03:20 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消