PHPackages                             sgb/think-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. sgb/think-validate

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

sgb/think-validate
==================

分离thinkphp5的validate类

1.1.4(8y ago)214PHP

Since Apr 18Pushed 8y ago1 watchersCompare

[ Source](https://github.com/carter911/php-validate)[ Packagist](https://packagist.org/packages/sgb/think-validate)[ RSS](/packages/sgb-think-validate/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)Dependencies (1)Versions (4)Used By (0)

thinkphp5-validate
------------------

[](#thinkphp5-validate)

使用tp5过程中发现validate还不错故将他剥离开来
----------------------------

[](#使用tp5过程中发现validate还不错故将他剥离开来)

`注意 由于只是用到了validate 代码里面有些小调整 去掉了多语言功能`

### 第一步引入

[](#第一步引入)

### 第二步

[](#第二步)

```
    //待验证的控制器
    include_once "../vendor/autoload.php";
    include_once "./Validate/UserValidate.php";
    $user = new \Validate\UserValidate();
    $param = "";
    if(!$user->scene('ret')->check( $param ))
    {
        $user->getError();
    }
```

```
    //Validate/UserValidate.php
    namespace Validate;

    use think5\Validate;

    class UserValidate extends Validate {

        protected $rule =   [
            'name'  => 'require|max:25',
            'age'   => 'number|between:1,120',
        ];

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

        protected $scene = [
            //流标场景
            'ret' => ['name','age','email'],
        ];
    }
```

具体的验证规则请移步至thinkphp5 [ thinkphp5-规则验证 ](https://www.kancloud.cn/manual/thinkphp5/129319)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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 ~3 days

Total

3

Last Release

2943d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/62441908ccc87091dbf41dcb2a3103eea8da9f7048b65ce164b0da4c91fed073?d=identicon)[路上](/maintainers/%E8%B7%AF%E4%B8%8A)

---

Top Contributors

[![carter911](https://avatars.githubusercontent.com/u/13519736?v=4)](https://github.com/carter911 "carter911 (7 commits)")

### Embed Badge

![Health badge](/badges/sgb-think-validate/health.svg)

```
[![Health](https://phpackages.com/badges/sgb-think-validate/health.svg)](https://phpackages.com/packages/sgb-think-validate)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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