PHPackages                             jinzhisu/php-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. jinzhisu/php-validator

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

jinzhisu/php-validator
======================

PHP Validator.

020PHP

Since Nov 9Pushed 7y agoCompare

[ Source](https://github.com/endwiki/php-validator)[ Packagist](https://packagist.org/packages/jinzhisu/php-validator)[ RSS](/packages/jinzhisu-php-validator/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Validator
=============

[](#php-validator)

前言
--

[](#前言)

公司里的用的是 Yii 框架， Yii 习惯上使用模型校验。而其他框架大都实现了更灵活的校验类。所以自己封装了一个类似的校验类，以 方便在接口处(区别于模型中)对客户端的传值进行校验。

安装
--

[](#安装)

建议使用 composer 进行安装。

基本使用
----

[](#基本使用)

基本使用如下:

```
$requestParams = [
    'name' => 'admin',
    'age' => 100,
    'tel' => '18969143101',
];

class UserValidator extends \JinZhiSu\Validator
{
    protected $ruleMap = [
        'name' => ['required'],
        'age' => ['Integer', 'Min:0', 'Max:125'],
        'tel' => ['required', 'Phone'],
    ];

    protected $message = [
        'name' => '姓名必填',
        'age' => '年龄必须为整数,必须在0到125之间',
        'tel' => '手机号码格式不正确',
    ];

    protected $defaultValues = [
        'age' => 1
    ];
}

$validator = new UserValidator($requestParams);
if (!$validator->check()) {
    var_dump($validator->getLastError());
    die();
}
var_dump($validator->getData());

```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/06ef375e1202b627d47f834048a80f43fa011d6a816a37186ff31ee67a1f2193?d=identicon)[JinZhiSu](/maintainers/JinZhiSu)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/jinzhisu-php-validator/health.svg)

```
[![Health](https://phpackages.com/badges/jinzhisu-php-validator/health.svg)](https://phpackages.com/packages/jinzhisu-php-validator)
```

###  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)
