PHPackages                             mapolun/easyswoole-normal-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. mapolun/easyswoole-normal-validate

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

mapolun/easyswoole-normal-validate
==================================

This is a validate using TP5 in conjunction with the easyswoole specification

v1.0.5(6y ago)2133MITPHPPHP &gt;=7.2.0

Since Aug 18Pushed 6y ago1 watchersCompare

[ Source](https://github.com/mapolun/easyswoole-normal-validate)[ Packagist](https://packagist.org/packages/mapolun/easyswoole-normal-validate)[ RSS](/packages/mapolun-easyswoole-normal-validate/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (3)Used By (0)

This is a validate using TP5 in conjunction with EasyS specification

运行easyswoole的validate结合tp5的验证规则，可自定义func。 验证的规则使用可以参考easyswoole官方的validate，

Installation
------------

[](#installation)

The recommended method of installing this library is via [Composer](https://getcomposer.org/).

Run the following command from your project root:

```
$ composer require mapolun/easyswoole-normal-validate
```

Requirements
------------

[](#requirements)

- EasySwoole
- PHP &gt;= 7.2

Usage
-----

[](#usage)

```
使用规则借鉴tp5规则语法，EasySwoole验证调用方法，验证字段规则值时用~ 符号隔开，可拓展func类型标识自定义函数进行验证规则。

一、创建validate规则

namespace App\Validate;

use MaPoLun\Validate;

/**
 * 登录验证类
 * Class SignIn
 * @package App\Validate\User
 */
class SignIn extends Validate
{
    protected $rule = [
        'username' => 'required|notEmpty',
        'password' => 'required|notEmpty|betweenLen:8~11',
    ];

    protected $message = [
        'username.required' => "缺少必要参数username",
        'username.notEmpty' => "username不可为空",
        'password.required' => "缺少必要参数password",
        'password.notEmpty' => "password不可为空",
        'password.betweenLen' => "password不合法"
    ];
}

二、创建控制器类

namespace App\HttpController;

use App\Validate\SignIn;

class Index extends Base
{
    public function index()
    {
        // TODO: Implement index() method.
        $validate = (new SignIn())->getExamplie();
        $params = $this->validateCheck($validate);
        var_dump($params); // 这是你客户端请求过来验证好的参数
    }
}

三、创建Base类

namespace App\HttpController;

use EasySwoole\Http\AbstractInterface\Controller;
use EasySwoole\Http\Message\Status;
use EasySwoole\Validate\Validate;
use Swoole\Coroutine\Http\Client\Exception;

class Base extends Controller
{
    public function index()
    {
        // TODO: Implement index() method.
    }

    public final function validateCheck($validate) : array
    {
        if ($validate instanceof Validate) {
            if ($this->validate($validate)) {
                return $validate->getVerifiedData();
            } else {
                throw new Exception($validate->getError()->__toString(),Status::CODE_ACCEPTED);
            }
        } else {
            throw new Exception("不属于规则合法验证实例",Status::CODE_INTERNAL_SERVER_ERROR);
        }
    }

    protected function onException(\Throwable $throwable): void
    {
        // TODO: Change the autogenerated stub
        $this->writeJson($throwable->getCode(),'fail',$throwable->getMessage());
        return;
    }
}
```

Last
----

[](#last)

喜欢的给我打星星哦，感谢！！！

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2507d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/33946264?v=4)[麻婆](/maintainers/mapolun)[@mapolun](https://github.com/mapolun)

---

Top Contributors

[![mapolun](https://avatars.githubusercontent.com/u/33946264?v=4)](https://github.com/mapolun "mapolun (11 commits)")

### Embed Badge

![Health badge](/badges/mapolun-easyswoole-normal-validate/health.svg)

```
[![Health](https://phpackages.com/badges/mapolun-easyswoole-normal-validate/health.svg)](https://phpackages.com/packages/mapolun-easyswoole-normal-validate)
```

###  Alternatives

[chaoswey/taiwan-id-validator

台灣身分證、統一編號驗證

319.9k](/packages/chaoswey-taiwan-id-validator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
