PHPackages                             hyperf-plus/validate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. hyperf-plus/validate

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

hyperf-plus/validate
====================

hyperf-plus validate 基于 hyperf/validation 的路由验证适配器，支持注解式验证

v4.0.4(5mo ago)49.6k↓50%23Apache-2.0PHPPHP &gt;=8.1CI passing

Since Sep 23Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/hyperf-plus/validate)[ Packagist](https://packagist.org/packages/hyperf-plus/validate)[ RSS](/packages/hyperf-plus-validate/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (21)Used By (3)

HPlus Validate 4.0
==================

[](#hplus-validate-40)

[![PHP Version](https://camo.githubusercontent.com/04744bae0a61d2ffe29c26f07a9612eae20445fc6feaeb77b3af1f0e9be6447c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d3838393242462e737667)](https://php.net)[![Hyperf Version](https://camo.githubusercontent.com/7dc19e7a52cb13e2f5eba7d76fd0bfba4d243a9f573d1ea124907388f0af5a21/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6879706572662d253345253344332e312d627269676874677265656e2e737667)](https://hyperf.io)[![License](https://camo.githubusercontent.com/798509b4df525f56802b56f8096862487f08023e3d7561c68656f8dab10d0d6e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4170616368652d2d322e302d626c75652e737667)](LICENSE)[![CI](https://camo.githubusercontent.com/2983409ae0db0a54c347e9f74a4a793e66f5a987ed23308edccac3189866766e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f43492d476974487562253230416374696f6e732d626c7565)](https://github.com/hyperf-plus/validate/actions)

基于 `hyperf/validation` 的请求验证组件，支持注解式验证和 FormRequest 验证器。 内置中文错误提示兜底、本地无语言包也能返回中文；默认安全过滤多余字段，可选安全模式拒绝未定义字段。

✨ 4.0 新特性
---------

[](#-40-新特性)

- 🚀 **Hyperf 原生验证**：完全基于 hyperf/validation，兼容所有 Laravel 规则
- 📝 **双模式**：内联规则 + FormRequest 验证器，支持场景
- ⚡ **性能优化**：多层缓存（配置/类检查/字段列表），更快
- 🛡️ **安全稳定**：可选安全模式拦截未定义字段，内置中文错误兜底，无语言包仍返回中文
- 🔧 **Query/Body 分离**：清晰区分 URL 参数与请求体校验
- ✅ **CI 覆盖**：GitHub Actions 多 PHP 版本自动化测试

> ⚠️ **破坏性变更**: 4.0 版本移除了 ThinkPHP 风格的 `Validate` 基类，仅支持 Hyperf 原生 `FormRequest`。

📦 安装
----

[](#-安装)

```
composer require hyperf-plus/validate:^4.0
```

### 依赖

[](#依赖)

```
composer require hyperf/validation hyperf/translation
php bin/hyperf.php vendor:publish hyperf/translation
```

🚀 快速开始
------

[](#-快速开始)

### 方式一：内联规则（推荐）

[](#方式一内联规则推荐)

```
