PHPackages                             jsyqw/param-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. jsyqw/param-validate

ActiveYii2-extension[Validation &amp; Sanitization](/categories/validation)

jsyqw/param-validate
====================

基于Yii2框架，对接口的统一验证的验证器

0.0.2(3y ago)0141PHP

Since Apr 10Pushed 3y ago1 watchersCompare

[ Source](https://github.com/jasonyqwang/param-validate)[ Packagist](https://packagist.org/packages/jsyqw/param-validate)[ RSS](/packages/jsyqw-param-validate/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (1)

开发 Yii2 的参数验证的扩展包
=================

[](#开发-yii2-的参数验证的扩展包)

```
基于Yii2框架的验证器，针对接口可以自动验证声明的参数；
经过验证的参数，可以直接访问属性，不用再通过isset判断；
验证规则和Yii2的rules规则一样

```

一.使用composer安装
==============

[](#一使用composer安装)

1.安装
----

[](#1安装)

```
    composer require jsyqw/param-validate

```

2.使用
----

[](#2使用)

在控制器的方法中

```
/**
     * 列表
     * 默认分页参数
     *      每页条数：per_page
     *      第几页： page
     * @return array
     */
    public function actionIndex(){
        $reqData = RequestHelper::get();
        //验证
        $validateModel = ParamsValidate::validate($reqData, [
            [['page','per_page'], 'integer'],
            ['username', 'filter', 'filter' => 'trim'],
            ['realname', 'filter', 'filter' => 'trim'],
            ['status', 'integer', 'message' => '状态参数必须是整型'],
            ['phone', 'safe'],
        ]);
        if($validateModel->hasErrors()){
            return $this->paramsError($validateModel->getFirstErrorMsg());
        }
        $query = new Query();
        $columns = [
            't.id',
            't.status',
            't.username',
            't.avatar',
            't.realname',
            't.phone',
            't.create_time',
            't.update_time',
        ];
        $query->select($columns);
        $query->from(SysUser::tableName() . ' t');
        $query->andFilterWhere([
            't.status' => $validateModel->status,
        ]);
        $query->andFilterWhere(['like', 't.username', $validateModel->username])
            ->andFilterWhere(['like', 't.realname', $validateModel->realname])
            ->andFilterWhere(['like', 't.phone', $validateModel->phone]);
        $query->orderBy('t.id desc');
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);
        $list = $dataProvider->getModels();
        $total = $dataProvider->getTotalCount();
        $result = [
            'list' => $list,
            'total' => $total,
        ];
        return $this->success($result);
    }
```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity34

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

Unknown

Total

1

Last Release

1132d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/56a4c0ae3dbcd1e806189f5c0b8a60543f35a786226aa267af1f8a8b55bd9af1?d=identicon)[jasonyqwang](/maintainers/jasonyqwang)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/jsyqw-param-validate/health.svg)

```
[![Health](https://phpackages.com/badges/jsyqw-param-validate/health.svg)](https://phpackages.com/packages/jsyqw-param-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)
