PHPackages                             bitdevelopment/yii2-validators - 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. bitdevelopment/yii2-validators

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

bitdevelopment/yii2-validators
==============================

Set of validators that doesn't exist in Yii by default

v1.1.1(6y ago)0691BSD-3-ClausePHPPHP &gt;=4.3.0

Since Jul 11Pushed 6y ago1 watchersCompare

[ Source](https://github.com/bitdevelopment/yii2-validators)[ Packagist](https://packagist.org/packages/bitdevelopment/yii2-validators)[ Docs](https://github.com/bitdevelopment/yii2-validators)[ RSS](/packages/bitdevelopment-yii2-validators/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (3)Used By (0)

yii2-validators
===============

[](#yii2-validators)

Yii2-validators are validators for yii for some specific cases that are not covered by standard yii2 validators. Currently it holds 2 validators but will be extended in future.

- WordCount Validator
- ReCaptcha Validator and InputWidget

Recaptcha validator and InputWidget is having new features:

- Compatible with Pjax
- Added ability to have more than one ReCaptcha widget on same page

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/). Check the [composer.json](https://github.com/bitdevelopment/yii2-validators/blob/master/composer.json) for this extension's requirements and dependencies.

To install, either run

```
$ php composer.phar require bitdevelopment/yii2-validators "v1.1.0"

```

or add

```
"bitdevelopment/yii2-validators": "v1.1.0"

```

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

Latest Release
--------------

[](#latest-release)

> NOTE: The latest version of the module is v1.1.0.

Usage
-----

[](#usage)

### WordCount Validator

[](#wordcount-validator)

Add validator to your rules list in your model

```
use bitdevelopment\yii2validators\WordValidator;

class Post extends \yii\base\Model {

  public function rules() {
    return [
            [['myField'],WordValidator::className(),'min'=>200,'max'=>500]
    ];
  }
  ...
```

If you want to validation occurs while user is typing you can use validateOnType option, for example:

```
$form->field($model, 'comment',['validateOnType' => true])->textarea([
                    'rows'=> 15
            ]);
```

> Since version v1.1.0 stripTags feature has been added, that strips HTML tags before it counts words, by default stripTags is setup to false.

### ReCaptcha Validator and Widget setup

[](#recaptcha-validator-and-widget-setup)

There are two ways of setting ReCaptcha Validator in your project, one is inline setup, if you decide to use multiple key:secret pairs and setup in your `params.php` file if you have global setup

##### Setting up in params

[](#setting-up-in-params)

In your `params.php` file of your project setup new key so it will look like this:

```
return [
       /*
	* Your params...
	*/
 	'reCaptcha' => [
        	'siteKey' => 'site_key',
        	'secret' => 'secret_key',
    	],
];
```

Note that `site_key` and `secret_key` you can obtain on your [Google ReCaptcha Admin](https://www.google.com/recaptcha/admin).

Now let's setup validation in your Model:

```
use bitdevelopment\yii2validators\ReCaptchaValidator;

class Post extends \yii\base\Model {

  public $reCaptcha;

  public function rules() {
    return [
            [['reCaptcha'], ReCaptchaValidator::className()],
	    [['reCaptcha'], 'required'],
    ];
  }
  ...
```

And Last step is to setup inputWidget on your view file, where your form is:

```
echo $form->field($comments, 'reCaptcha')->widget(
            	bitdevelopment\yii2validators\ReCaptcha::className(),
        )->label(false) ?>
```

##### Inline Settings

[](#inline-settings)

Similarly like when setting up with `params.php` you can setup params inline against a field, like in this example:

```
  //In your rules
  [['reCaptcha'], ReCaptchaValidator::className(),'secret'=>'secret_key'],
  ...
```

```
  //In your view
  echo $form->field($comments, 'reCaptcha')->widget(
            	bitdevelopment\yii2validators\ReCaptcha::className(),
		['siteKey','site_key']
        )->label(false) ?>
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.3% 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 ~773 days

Total

2

Last Release

2503d ago

### Community

Maintainers

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

---

Top Contributors

[![crnimilos](https://avatars.githubusercontent.com/u/1808492?v=4)](https://github.com/crnimilos "crnimilos (12 commits)")[![bitdevelopment](https://avatars.githubusercontent.com/u/16432537?v=4)](https://github.com/bitdevelopment "bitdevelopment (1 commits)")

---

Tags

wordyii2extensionwidgetformvalidatorscountdependent

### Embed Badge

![Health badge](/badges/bitdevelopment-yii2-validators/health.svg)

```
[![Health](https://phpackages.com/badges/bitdevelopment-yii2-validators/health.svg)](https://phpackages.com/packages/bitdevelopment-yii2-validators)
```

###  Alternatives

[kartik-v/yii2-widget-depdrop

Widget that enables setting up dependent dropdowns with nested dependencies (sub repo split from yii2-widgets)

815.1M18](/packages/kartik-v-yii2-widget-depdrop)[kartik-v/yii2-detail-view

Enhanced Yii 2 Detail View widget with special Bootstrap styles, ability to edit data, and more.

701.2M41](/packages/kartik-v-yii2-detail-view)[kartik-v/yii2-widget-colorinput

An enhanced Yii 2 widget encapsulating the HTML 5 color input (sub repo split from yii2-widgets)

325.0M10](/packages/kartik-v-yii2-widget-colorinput)[thiagotalma/yii2-jstree

Widget for Yii Framework 2.0 to use JsTree

3263.0k2](/packages/thiagotalma-yii2-jstree)[bryglen/yii2-validators

credit card validation yii 2

1426.9k](/packages/bryglen-yii2-validators)

PHPackages © 2026

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