In my Java EE 7 OpenShift project I'm using javaee-api version 7.0. For my model I added the depency validation-api version 1.1.0, but that wasn't enough. Then I tried with
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.2.4.Final</version>
<scope>provided</scope>
</dependency>
and this works. Is the validation-api implicit in this depency?
Bean Validation and Hibernate Validator
The Hibernate Validator is the reference implementation of the Bean Validation 1.1 specification.
Check the Maven Repository, for example, and you'll realize the
hibernate-validatorartifact does include thevalidation-apiartifact as a dependency.Bean Validation and Java EE 7 API
The Bean Validation is defined in the
javax.validationpackage and sub-packages.The Java EE 7 is an umbrella specification and, among other specifications, it includes the Bean Validation 1.1 specification.
It means the
javaee-apiartifact includes thejavax.validationpackage and sub-packages. However, no implementation for the Bean Validation is provided as dependency of that artifact.In the other hand, some containers, such as WildFly and GlassFish, provide the Hibernate Validator dependency (or any other Bean Validation implementation) to be compliant with the Java EE 7 specification. In this situation, if you want to use something specific from the Hibernate Validator (that is, something from the
org.hibernate.validatorpackage or sub-packages), you need to add thehibernate-validatordependency with theprovidedscope.Otherwise, if you won't use anything specific from the Hibernate Validator, the
javaee-apidependency should be just fine.