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

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

webtoolsnz/yii2-validators
==========================

A collection of yii2 validators.

0.1.8(6y ago)067.6k—7%proprietaryPHP

Since Jul 5Pushed 5y ago15 watchersCompare

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

READMEChangelog (7)Dependencies (3)Versions (10)Used By (0)

Yii2 Validators
===============

[](#yii2-validators)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/1a9352e4228baa771f9737edec4017ce113d274973b041aaeb94e6a497e241a0/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f776562746f6f6c736e7a2f796969322d76616c696461746f72732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/webtoolsnz/yii2-validators)[![Coverage Status](https://camo.githubusercontent.com/c96f570c8a3e08bf2b75dec8549fa4eda97913b014c0ccc38cffcb3a8f982353/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f776562746f6f6c736e7a2f796969322d76616c696461746f72732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/webtoolsnz/yii2-validators/code-structure)[![Quality Score](https://camo.githubusercontent.com/be62fd2723b8406ed745bae23669b003998de59da31f36f8f76cbd0eb3f7c294/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f776562746f6f6c736e7a2f796969322d76616c696461746f72732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/webtoolsnz/yii2-validators)

A collection of Yii2 validators for various localities.

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

[](#installation)

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

```
$ composer require webtoolsnz/yii2-validators
```

Example Use
-----------

[](#example-use)

### Model Validation rules

[](#model-validation-rules)

```
use webtoolsnz\validators\en_AU\NmiValidator;

class MyModel extends \yii\base\Model
{
    public function rules()
    {
        return [
            [['nmi'], NmiValidator::className()]
        ];
    }
}

```

### Adhoc Validation

[](#adhoc-validation)

```
$validator = new webtoolsnz\validators\en_AU\NmiValidator();
$validator->validate('NGGG0000554');

```

Available Validators
--------------------

[](#available-validators)

- PasswordStrengthValidator
- PhoneNumberValidator

### en\_AU

[](#en_au)

- NmiValidator
- AbnValidator
- PhoneNumberValidator

### en\_GB

[](#en_gb)

- PostCodeValidator
- PhoneNumberValidator

### Phone Number Validation

[](#phone-number-validation)

Use `webtoolsnz\validators\en_GB\PhoneNumberValidator` or `webtoolsnz\validators\en_AU\PhoneNumberValidator` for simpilicity (no options required) for other regions use `webtoolsnz\validators\PhoneNumberValidator`

Options defined as follows

```
$rules = [
   [
       'phone',
       webtoolsnz\validators\PhoneNumberValidator::className(),
            // ISO 2 letter country code - Required (unless using en_GB or en_AU versions) will convert
            // 021 => +6421
        'expectedRegion' => 'NZ',

            // auto fills expectedRegion - phone number MUST be from this region
        'requiredRegion' => 'NZ',

            // number is required to match type, NUMBER_TYPE_FIXED_LINE is also available
        'numberType' => PhoneNumberValidator::NUMBER_TYPE_MOBILE,

            // will re-format input to match the given format. Values are FORMAT_NATIONAL FORMAT_E164 and FORMAT_INTERNATIONAL
        'format' => PhoneNumberValidator::FORMAT_E164,

        // some error messages are also customizable
];
```

Testing
-------

[](#testing)

`webtoolsnz/yii2-validators` has a [PHPUnit](https://phpunit.de) test suite. To run the tests, run the following command from the project folder.

```
$ composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](LICENSE) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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 ~220 days

Recently: every ~423 days

Total

9

Last Release

2209d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0fe4edc8748b6ac4922ab8d16f64de61ad0b552027d8c1630646f6a0d6f09b9d?d=identicon)[badams](/maintainers/badams)

![](https://www.gravatar.com/avatar/3294557eec40b2b2b57c3f4a04e3ce15c80c791bff21a93d12832b44975ebe5c?d=identicon)[brucealdridge](/maintainers/brucealdridge)

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

![](https://www.gravatar.com/avatar/a002d46764f9a0765a077837aec2e53e940607948ef3304be02adc0310f64d50?d=identicon)[webtools-machine-user](/maintainers/webtools-machine-user)

---

Top Contributors

[![brucealdridge](https://avatars.githubusercontent.com/u/57298?v=4)](https://github.com/brucealdridge "brucealdridge (12 commits)")[![badams](https://avatars.githubusercontent.com/u/340715?v=4)](https://github.com/badams "badams (2 commits)")[![hugowebtools](https://avatars.githubusercontent.com/u/50603301?v=4)](https://github.com/hugowebtools "hugowebtools (1 commits)")

---

Tags

yii2validators

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[borales/yii2-phone-input

Yii2 International telephone numbers - Asset Bundle, Behavior, Validator, Widget

1341.6M6](/packages/borales-yii2-phone-input)[codeonyii/yii2-at-least-validator

Validates at least one (or more) attributes.

28253.5k1](/packages/codeonyii-yii2-at-least-validator)[yii2mod/yii2-validators

Collection of useful validators for Yii Framework 2.0

1816.8k](/packages/yii2mod-yii2-validators)[bryglen/yii2-validators

credit card validation yii 2

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

PHPackages © 2026

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