| <!--- |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| --> |
| <div align="center"> |
| <img src="https://bval.apache.org/resources/images/logo.png" width="300" /> |
| </div> |
| <br> |
| |
|  |
| [](https://opensource.org/licenses/Apache-2.0) |
| [](https://github.com/apache/bval/actions/workflows/bval-ci.yml) |
| |
| Apache BVal - Apache's implementation of the Jakarta Validation specification for Jakarta EE and Java SE |
| |
| ## Branches |
| |
| ### master / 4.0.x |
| Jakarta Validation 4.0 implementation (Jakarta EE 12, WIP), requires Java 17+. |
| |
| ### 3.1.x |
|  |
| Jakarta Validation 3.1 implementation (Jakarta EE 11), requires Java 17+. |
| |
| ### 3.0.x |
|  |
| Jakarta Bean Validation 3.0 implementation (Jakarta EE 10), requires Java 11+. |
| |
| ### 2.x |
|  |
| Bean Validation 2.0 (JSR-380) implementation (Java EE 8), requires Java 8+. |
| |
| ### 1.1.x |
|  |
| Bean Validation 1.1 (JSR-349) implementation (Java EE 7), requires Java 6+. |
| |
| ## Minimum Requirements (master) |
| |
| - Java 17+ |
| - Jakarta Validation 4.0 (Jakarta EE 12) |
| - TCK compliant |
| |
| ## Installation |
| |
| ```shell |
| mvn clean install |
| ``` |
| |
| ## Usage |
| |
| ### Dependency |
| |
| ```xml |
| <dependency> |
| <groupId>org.apache.bval</groupId> |
| <artifactId>bval-jsr</artifactId> |
| <version>${bval.version}</version> |
| </dependency> |
| ``` |
| |
| ### Optional: extra constraints |
| |
| ```xml |
| <dependency> |
| <groupId>org.apache.bval</groupId> |
| <artifactId>bval-extras</artifactId> |
| <version>${bval.version}</version> |
| </dependency> |
| ``` |
| |
| ### Optional: OSGi bundle |
| |
| ```xml |
| <dependency> |
| <groupId>org.apache.bval</groupId> |
| <artifactId>org.apache.bval.bundle</artifactId> |
| <version>${bval.version}</version> |
| </dependency> |
| ``` |
| |
| ### Basic usage |
| |
| ```java |
| ValidatorFactory validatorFactory = Validation |
| .byProvider(ApacheValidationProvider.class) |
| .configure() |
| .buildValidatorFactory(); |
| |
| Validator validator = validatorFactory.getValidator(); |
| Set<ConstraintViolation<MyBean>> violations = validator.validate(myBean); |
| ``` |
| |
| ## More Information |
| |
| Please visit https://bval.apache.org for full documentation and release notes. |
| |
| Issue tracker: https://issues.apache.org/jira/browse/BVAL |