PHPackages                             hsucy/validation - 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. hsucy/validation

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

hsucy/validation
================

userd for validation

010PHP

Since Aug 14Pushed 7y ago1 watchersCompare

[ Source](https://github.com/sasuke6/validation)[ Packagist](https://packagist.org/packages/hsucy/validation)[ RSS](/packages/hsucy-validation/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Validation for PHP project
==========================

[](#validation-for-php-project)

### How to use

[](#how-to-use)

#### 1、Install

[](#1install)

```
composer require hsucy/validation dev-master

```

#### 2、Create Input Form

[](#2create-input-form)

for example

```
use Hsucy\Validation\Validate;

class UserForm extends Validate
{
    // rule
    public function rules()
    {
        return [
            'age'   => ['integer', 'unsigned' => true, 'min' => 1, 'max' => 120],
        ];
    }

    // scenario
    public function scenarios()
    {
        return [
            'create' => ['required' => ['age']],
        ];
    }

    // message
    public function messages()
    {
        return [
            'age.integer'    => 'message',
            'age.unsigned'   => 'message',
            'age.min'        => 'message',
            'age.max'        => 'message',
        ];
    }
}

```

At first,you should create form class extend from the `Hsucy\Validation\Validate`,and set the **rules**,**scenarios** and **message**.The **rules** is userd for the validation of request data,and the **scenarios** decide the operation of rules.At last,the **message** return the error tips.

#### 3、Set up the attriubte to form

[](#3set-up-the-attriubte-to-form)

for example

I use the easyswoole framework

```
$model = new UserForm();
$model->attributes = $this->request()->getRequestParam();
$model->setScenario('create');
if (!$model->validate()) {
    $this->writeJson(402,  [],  $model->getErrors());
       return true;
}
$this->response()->write('this is controller test2 and your id is '.$this->request()->getRequestParam('age'));

```

create the new class **UserForm**,then set up the attribute and scenario.At last,use validate method to excute the validation

Thanks.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/138109?v=4)[hsu](/maintainers/hsu)[@hsu](https://github.com/hsu)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/hsucy-validation/health.svg)

```
[![Health](https://phpackages.com/badges/hsucy-validation/health.svg)](https://phpackages.com/packages/hsucy-validation)
```

###  Alternatives

[chaoswey/taiwan-id-validator

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

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

PHPackages © 2026

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