PHPackages                             shopwwi/webman-validator - 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. shopwwi/webman-validator

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

shopwwi/webman-validator
========================

webman validator

v1.0(4y ago)010MITPHPPHP &gt;=7.2

Since Mar 11Pushed 4y agoCompare

[ Source](https://github.com/shopwwi/webman-validator)[ Packagist](https://packagist.org/packages/shopwwi/webman-validator)[ RSS](/packages/shopwwi-webman-validator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

安装
==

[](#安装)

```
composer require shopwwi/webman-validator

```

\#说明

```
此为webman专用插件 原型为thinkphp验证包含TP验证所有内容 有些不明白的可查看TP验证文档

```

使用方法
----

[](#使用方法)

### 验证器定义

[](#验证器定义)

```
//定义一个验证器
namespace app\validator;

use Shopwwi\WebmanValidator\Validator;

class User extends Validator
{
    protected $rule =   [
        'name'  => 'require|max:25',
        'age'   => 'number|between:1,120',
        'email' => 'email',
    ];

    protected $message  =   [
        'name.require' => '名称必须',
        'name.max'     => '名称最多不能超过25个字符',
        'age.number'   => '年龄必须是数字',
        'age.between'  => '年龄只能在1-120之间',
        'email'        => '邮箱格式错误',
    ];
}
//验证方法
