🌍 选择语言/Select Language:
Hibernate Validator Plus is an enhanced validation framework based on Hibernate Validator, providing rich validation annotations, flexible group validations, and unified validation utilities.
📦 Features: - Built-in commonly used validation annotations (account, password, ID card, IPv4, etc.) - Multiple built-in validation group schemes - International i18n, supports Chinese, English, Japanese, Chinese, Russian, French, Spanish, etc.. - Built-in allowable null judgment - It remains fully compatible with the Hibernate Validator native framework and can directly use all its built-in validation functions. - There are fewer dependencies, the architecture is more lightweight, and there is no forced dependence on other frameworks (such as spring). - Supports the direct introduction of Spring MVC and Spring Boot projects, can automatically verify, and provides manual calling of tool classes. - Support jdk8 or jdk8 or above version
Location: annotation
| Annotation | Purpose | Description |
|---|---|---|
@CAccount |
Account validation | Starts with a letter, 5–16 chars, alphanumeric + _ |
@CPassword |
Password validation | 6–18 chars, with at least 1 letter and at least 1 number. |
@CIdCard |
ID card validation | Supports common CN ID formats |
@CPhone |
Phone validation | Mainland China mobile numbers |
@CPassport |
Passport validation | Default: CN passport format; supports region parameter switching CN/US/JP/UK/KR |
@CPostCode |
Postcode validation | Default: CN postcode format; supports region parameter switching CN/US/JP/UK/KR |
@CFile |
File validation | Default max size 1 MB, file suffix supported |
@CPlateNumber |
Plate number check | Supports both new & old CN vehicle plates |
@CIpv4 |
Ipv4 validation | Standard IPv4 address format |
@CIpv6 |
IPv6 Validation | Standard IPv6 address format |
@CDateRange |
Date range check | min start date, max end date ,recommend format:yyyy-MM-dd HH:mm:ss |
@CBankCard |
BankCard Validation | Bank card number verification uses the Luhn algorithm by default, and you can specify the interception card number prefix. |
@CUrl |
URL Validation | URL format verification |
@CMoney |
Money Validation | Amount format verification |
Supports verification of amount formats of numbers, strings or BigDecimal types |
| @CMacAddress | Mac Address Validation | Mac Address Validation |
Location: groups
| Group Name | Purpose |
|---|---|
@CCreate |
Create operation |
@CCreateDef |
Create + default checks |
@CQuery |
Query operation |
@CQueryDef |
Query + default checks |
| ... | More extensions supported |
CValid provides multiple validation capabilities, including standard validation(Full Check), fast-fail validation, property-level validation, and group-based validation.
Exception Class:ValidationException
| Method Type | Validation Mode | Failure Behavior | Return Type |
|---|---|---|---|
validate(Object object) |
validate(Object object, Class<?>... groups) | Fast-Fail ⚡ | Throws Exception ❗ | void |
| tryValidate(Object object)
tryValidate(Object object, Class<?>... groups) | Full Check | No Exception | List |
| tryFastValidate(Object object)
tryFastValidate(Object object, Class<?>... groups) | Fast-Fail ⚡ | No Exception | String |
| validateProperty(Object object, String propertyName, Class<?>... groups) | Fast-Fail ⚡ | Throws Exception ❗ | void |
| tryValidateProperty(Object object, String propertyName, Class<?>... groups) | Full Check | No Exception | List |
| tryFastValidateProperty(Object object, String propertyName, Class<?>... groups) | Fast-Fail ⚡ | No Exception | String |
Demo Spring Boot project:
🔗 https://github.com/carpcap/hibernate-validator-plus-demo
<dependency>
<groupId>com.carpcap</groupId>
<artifactId>hibernate-validator-plus</artifactId>
<version>1.2.2</version>
</dependency>
Declare validation groups:

Automatic validation through Spring MVC:

Manual validation using the provided utility class. Validation failures will throw ValidationException:

This project is released under the Apache License 2.0.
You can find the full license text in the project's root directory (LICENSE), or visit:
$ claude mcp add hibernate-validator-plus \
-- python -m otcore.mcp_server <graph>