PHPackages                             nsp-team/validator-tool - 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. nsp-team/validator-tool

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

nsp-team/validator-tool
=======================

Provides tools to validate values

v0.0.2(4y ago)213Apache-2.0PHPPHP &gt;=7.3

Since Dec 21Pushed 4y agoCompare

[ Source](https://github.com/nsp-team/validator-tool)[ Packagist](https://packagist.org/packages/nsp-team/validator-tool)[ RSS](/packages/nsp-team-validator-tool/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

**nsp-team/validator-tool** 是一个非常小的验证库，尽可能的为我们创建的最简单和最有用的 API。

- 说明

    项目为  的汉化版本，优化了部分内容，增加了部分校验规则，如：Ip等。 另外PHP版本升级到7.3，使用强类型定义变量和返回值类型，用法保持不变。

> 提供了全部汉化的语义描述，当然您也可以覆盖当前已设置的语义描述，采用自定义的错误描述信息.

Install
-------

[](#install)

```
composer require nsp-team/validator-tool
```

Simple usage
------------

[](#simple-usage)

```
$v = new Validator;

$v->required('user.first_name')->lengthBetween(2, 50)->alpha();
$v->required('user.last_name')->lengthBetween(2, 50)->alpha();
$v->required('newsletter')->bool();

$result = $v->validate([
    'user' => [
        'first_name' => 'John',
        'last_name' => 'D',
    ],
    'newsletter' => true,
]);

$result->isValid(); // bool(false).
$result->getMessages();
/**
 * array(1) {
 *     ["user.last_name"]=> array(1) {
 *         ["Length::TOO_SHORT"]=> string(53) "last_name  字符串长度太短，必须在 80-120 个字符长度之间."
 *     }
 * }
 */
```

命名规范
----

[](#命名规范)

遵循PSR-2命名规范和PSR-4自动加载规范。

features
--------

[](#features)

- 零依赖
- 验证对象是数组参数
- 可以获取错误信息数组
- 提供了覆盖规则上的默认错误消息方式, 或特定值上的错误消息
- 获取数组的验证值
- 大量的默认验证规则
- 能够扩展验证器以添加您自己的自定义规则

文档
--

[](#文档)

后期我会提供一份教程文档使用方式，开发者可以先自定阅读源码。

Thanks
------

[](#thanks)

[particle-php/Validator](https://github.com/particle-php/Validator)

[yiisoft/validator](https://github.com/yiisoft/validator)

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

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.

###  Release Activity

Cadence

Every ~8 days

Total

2

Last Release

1597d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b9755903f7a6e3183dc76df22ec6c1db85fc54724e85c6e4351efbfd563bc07a?d=identicon)[19951591761](/maintainers/19951591761)

---

Top Contributors

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

---

Tags

phpsimplevalidatorvalidator

### Embed Badge

![Health badge](/badges/nsp-team-validator-tool/health.svg)

```
[![Health](https://phpackages.com/badges/nsp-team-validator-tool/health.svg)](https://phpackages.com/packages/nsp-team-validator-tool)
```

###  Alternatives

[respect/validation

The most awesome validation engine ever created for PHP

5.9k37.4M383](/packages/respect-validation)[seld/jsonlint

JSON Linter

1.3k217.8M205](/packages/seld-jsonlint)[composer/spdx-licenses

SPDX licenses list and validation library.

1.4k184.2M25](/packages/composer-spdx-licenses)[opis/json-schema

Json Schema Validator for PHP

64236.9M186](/packages/opis-json-schema)[intervention/validation

Additional validation rules for the Laravel framework

6826.7M8](/packages/intervention-validation)[laminas/laminas-validator

Validation classes for a wide range of domains, and the ability to chain validators to create complex validation criteria

15544.9M188](/packages/laminas-laminas-validator)

PHPackages © 2026

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