Is there an implementation of JSR-303 (bean validation) available?

倾然丶 夕夏残阳落幕 提交于 2019-11-26 09:35:24

问题


I know there are non-standard frameworks such as commons-validator, and hibernate validator.

I wanted to know if someone knows an implementation of the official standard.


回答1:


Hibernate Validator is the reference implementation of JSR-303




回答2:


There are 2 compliant implementations now:

  • Apache Bean Validation (formerly agimatec)
  • Hibernate Validator

You can access a benchmark and a quick description of both here: http://carinae.net/2010/06/benchmarking-hibernate-validator-and-apache-beanvalidation-the-two-jsr-303-implementations/




回答3:


Implementations:

  • agimatec-validation
  • Hibernate Validator



回答4:


OVaL is not a JSR-303 validator, but it can convert jsr303 constraints into its own.




回答5:


Spring Framework became JSR303 compliant from version 3 onward I think.

http://docs.spring.io/spring/docs/current/spring-framework-reference/html/validation.html#validation-beanvalidation

Spring Framework 4.0 supports Bean Validation 1.0 (JSR-303) and Bean Validation 1.1 (JSR-349) in terms of setup support, also adapting it to Spring’s Validator interface.




回答6:


As for summer 2018, there are three specifications that supersed each other:

  • JSR 380 (Bean Validation 2.0)
  • JSR 349 (Bean Validation 1.1)
  • JSR 303 (Bean Validation 1.0)

You can consult the official site for more details.

Hibernate Validator 6.10 is a reference implementation of the newest one (380). It has a great documentation I'd recommend to take a look at (however it's quite big stuff).

CUBA platform docs could give you a much shorter grasp of the topic if you need just a fast intro. CUBA framework is based on Spring and EclipseLink, so the things you've learned could be used on regular Spring+Hibernate projects as well :)

The JSR 349 is supported by older versions of Hibernate Validator and by Apache BVal, both of them are "official".

From ORMs other than Hibernate, EclipseLink supports JSR 349 and can use Validator interface provided by HV.

If it's possible, I would recommend to not use the older version (JSR 303) but switch to 349 or 380 specs. They are quite more mature and rich.

Bean Validation could be used in the project even there is no ORM in it, for example you can use it your Java 2SE or Android apps (see this article), however, this is not the approach Bean Validation was designed for as a primary thing. Although it's possible to use these validators (HV and BVal) just by itself (you'd have to instantiate and call Validator and ExecutableValidator manually), they will really shine working together with frameworks like Hibernate, Spring or CUBA



来源:https://stackoverflow.com/questions/1384968/is-there-an-implementation-of-jsr-303-bean-validation-available

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!