PHPackages                             cetver/yii2-validation-filters - 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. [Search &amp; Filtering](/categories/search)
4. /
5. cetver/yii2-validation-filters

ActiveYii2-extension[Search &amp; Filtering](/categories/search)

cetver/yii2-validation-filters
==============================

Validation filters for the Yii framework 2.0

1.1.3(5y ago)62.1k↓50%[11 PRs](https://github.com/cetver/yii2-validation-filters/pulls)BSD-3-ClausePHP

Since May 23Pushed 3y ago2 watchersCompare

[ Source](https://github.com/cetver/yii2-validation-filters)[ Packagist](https://packagist.org/packages/cetver/yii2-validation-filters)[ RSS](/packages/cetver-yii2-validation-filters/feed)WikiDiscussions master Synced 1mo ago

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

Validation filters for Yii 2
============================

[](#validation-filters-for-yii-2)

This extension provides a validation filters for the [Yii framework 2.0](http://www.yiiframework.com).

For license information check the [LICENSE](LICENSE)-file.

[![Build Status](https://camo.githubusercontent.com/c4b21b793c5a1b28057388aa005be1120485c59b83351a4151276c58fabc03cc/68747470733a2f2f7472617669732d63692e6f72672f6365747665722f796969322d76616c69646174696f6e2d66696c746572732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/cetver/yii2-validation-filters)[![Coverage Status](https://camo.githubusercontent.com/2b88d6fa286a1c48fd54263a0b5a6c7d4c79b738a748d9431cee348f4e6d0cfb/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6365747665722f796969322d76616c69646174696f6e2d66696c746572732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/cetver/yii2-validation-filters)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
composer require --prefer-dist cetver/yii2-validation-filters

```

or add

```
"cetver/yii2-validation-filters": "~1.0.0"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

### Available validation filters:

[](#available-validation-filters)

- [trim](#trim)
- [ltrim](#ltrim)
- [rtrim](#rtrim)
- [ucfirst](#ucfirst)
- [lcfirst](#lcfirst)
- [strtoupper](#strtoupper)
- [strtolower](#strtolower)
- [ucwords](#ucwords)
- [mb\_convert\_case](#mb_convert_case)

#### `trim`

[](#trim)

```
public function rules()
{
    return [
        [
            'attribute',
            \cetver\ValidationFilters\validators\TrimValidator::className(),
            'characterMask' => ' ' // optional, default value is " \t\n\r\0\x0B"
        ],
    ];
}
```

#### `ltrim`

[](#ltrim)

```
public function rules()
{
    return [
        [
            'attribute',
            \cetver\ValidationFilters\validators\LeftTrimValidator::className(),
            'characterMask' => ' ' // optional, default value is " \t\n\r\0\x0B"
        ],
    ];
}
```

#### `rtrim`

[](#rtrim)

```
public function rules()
{
    return [
        [
            'attribute',
            \cetver\ValidationFilters\validators\RightTrimValidator::className(),
            'characterMask' => ' ' // optional, default value is " \t\n\r\0\x0B"
        ],
    ];
}
```

#### `ucfirst`

[](#ucfirst)

```
public function rules()
{
    return [
        [
            'attribute',
            \cetver\ValidationFilters\validators\MultibyteUpperCharacterFirstValidator::className(),
            'encoding' => 'UTF-8' // optional, default value is mb_internal_encoding()
        ],
    ];
}
```

#### `lcfirst`

[](#lcfirst)

```
public function rules()
{
    return [
        [
            'attribute',
            \cetver\ValidationFilters\validators\MultibyteLowerCharacterFirstValidator::className(),
            'encoding' => 'UTF-8' // optional, default value is mb_internal_encoding()
        ],
    ];
}
```

#### `strtoupper`

[](#strtoupper)

```
public function rules()
{
    return [
        [
            'attribute',
            \cetver\ValidationFilters\validators\MultibyteConvertCaseValidator::className(),
            'mode' => MB_CASE_UPPER,
            'encoding' => 'UTF-8' // optional, default value is mb_internal_encoding()
        ],
    ];
}
```

#### `strtolower`

[](#strtolower)

```
public function rules()
{
    return [
        [
            'attribute',
            \cetver\ValidationFilters\validators\MultibyteConvertCaseValidator::className(),
            'mode' => MB_CASE_LOWER,
            'encoding' => 'UTF-8' // optional, default value is mb_internal_encoding()
        ],
    ];
}
```

#### `ucwords`

[](#ucwords)

```
public function rules()
{
    /**
    * NOTE:
    * ucwords('HELLO WORLD'); // HELLO WORLD
    * mb_convert_case('HELLO WORLD', MB_CASE_TITLE); // Hello World
    */
    return [
        [
            'attribute',
            \cetver\ValidationFilters\validators\MultibyteConvertCaseValidator::className(),
            'mode' => MB_CASE_TITLE,
            'encoding' => 'UTF-8' // optional, default value is mb_internal_encoding()
        ],
    ];
}
```

#### `mb_convert_case`

[](#mb_convert_case)

```
public function rules()
{
    return [
        [
            'attribute',
            \cetver\ValidationFilters\validators\MultibyteConvertCaseValidator::className(),
            /**
             * MB_CASE_UPPER - converts the attribute value uppercase.
             * MB_CASE_LOWER - converts the attribute value lowercase.
             * MB_CASE_TITLE - converts the first character of each word of the attribute value capitalized.
             */
            'mode' => MB_CASE_UPPER,
            'encoding' => 'UTF-8' // optional, default value is mb_internal_encoding()
        ],
    ];
}
```

Tests
-----

[](#tests)

```
composer create-project --prefer-source cetver/yii2-validation-filters

```

### PHP

[](#php)

```
cd yii2-validation-filters
php vendor/bin/codecept run --config tests/php/codeception.yml unit

```

### JavaScript

[](#javascript)

Open in browser `yii2-validation-filters/tests/js/index.html`

or

```
cd yii2-validation-filters
npm install
npm run build
npm run test

```

Credits
-------

[](#credits)

PHP functions written in JavaScript [locutus](https://github.com/kvz/locutus).

Browser-side require() the node.js way [browserify](https://github.com/substack/node-browserify).

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 89.5% 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 ~145 days

Recently: every ~290 days

Total

9

Last Release

2109d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1559b6aa16900ca791ceab70afe5c8a7ccbcedbf86408e87151f2ce7a17a130f?d=identicon)[cetver](/maintainers/cetver)

---

Top Contributors

[![cetver](https://avatars.githubusercontent.com/u/1411914?v=4)](https://github.com/cetver "cetver (17 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

validationfilteryii2filters

### Embed Badge

![Health badge](/badges/cetver-yii2-validation-filters/health.svg)

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

###  Alternatives

[thrieu/yii2-grid-view-state

Save filters from GridView to session, keep the filter state between pages.

1313.1k1](/packages/thrieu-yii2-grid-view-state)[cyneek/yii2-routes

Routing and filtering extension system for Yii2 framework that emulates the Laravel routing system.

202.1k](/packages/cyneek-yii2-routes)

PHPackages © 2026

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