Validation Framework in Java

2019-02-18 05:25发布

We are currently in the process of refactoring our plugin API**(JDK 1.4 compliant)** which is shipped to our clients in the form of a jar file(ie, no need to have javascripts to be generated and so forth). This is a very lightweight plugin so that we have kept away as many dependent jars as possible like Spring. During this process we started to understand the need to have a proper validation methodology which is faciliated by some validation Framework. Strangly, I couldnt find much options in these lines (like other open source projects)apart from a few such as Commons Validator,Drools and Spring support.

Drools seems to be so complex for my needs. However Commons validator looks prehistoric in its style of validation.

I cannot use annotation based validation cause it has to be JDK 1.4 and would prefer something that could be externalized thereby not requiring to compile classes again in case of changes.

Are there better options available?

6条回答
Juvenile、少年°
2楼-- · 2019-02-18 05:36

ValangValidator is a Spring-compatible validator that uses "valang" syntax such that if all you need is simple validations, you can just plug in a valang validator for your spring validator bean. ValangValidator also enables you to plug in your own custom function implementations. It is part of "springmodules".

See this link for more information.

查看更多
仙女界的扛把子
3楼-- · 2019-02-18 05:37

We're using the VLAD framework from sapia, can be configured via XML and BeanShell.

查看更多
爷的心禁止访问
4楼-- · 2019-02-18 05:42

If you prefer your validation rules in declarative style, you can try http://jvalidations.codehaus.org/

查看更多
家丑人穷心不美
5楼-- · 2019-02-18 05:42

I've recently found the JValidations framework. It's plain Java, no XML. Using Hamcrest matchers. Validation code is placed in the validated object itself. Neat.

查看更多
Bombasti
6楼-- · 2019-02-18 05:51

The XWork validation system was pretty decent back in the day but I haven't used it for almost 3 years now. I'm quite certain it was designed to be totally standalone but has also been rolled into Struts 2 along with the rest of WebWork. Info is here:

http://www.opensymphony.com/xwork/wikidocs/Validation%20Framework.html

查看更多
爷的心禁止访问
7楼-- · 2019-02-18 05:53

Try Hibernate Validator. It's primarily directed at using annotations, but is perfectly usable without. I used it a few times, and liked its model.

查看更多
登录 后发表回答