2017 © Pedro Peláez
 

yii2-extension yii2-validators

A collection of yii2 validators.

image

webtoolsnz/yii2-validators

A collection of yii2 validators.

  • Thursday, March 17, 2016
  • by badams
  • Repository
  • 6 Watchers
  • 0 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Yii2 Validators

Software License Build Status Coverage Status Quality Score, (*1)

A collection of Yii2 validators for various localities., (*2)

Installation

The preferred way to install this extension is through composer., (*3)

$ composer require webtoolsnz/yii2-validators

Example Use

Model Validation rules

use webtoolsnz\validators\en_AU\NmiValidator;

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

Adhoc Validation

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

Available Validators

  • PasswordStrengthValidator
  • PhoneNumberValidator

en_AU

  • NmiValidator
  • AbnValidator
  • PhoneNumberValidator

en_GB

  • PostCodeValidator
  • PhoneNumberValidator

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, (*4)

Options defined as follows, (*5)

$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

webtoolsnz/yii2-validators has a PHPUnit test suite. To run the tests, run the following command from the project folder., (*6)

bash $ composer test, (*7)

License

The MIT License (MIT). Please see LICENSE for more information., (*8)

The Versions

17/03 2016

dev-master

9999999-dev https://github.com/webtoolsnz/yii2-validators

A collection of yii2 validators.

  Sources   Download

proprietary

The Requires

 

The Development Requires

yii2 validators

14/03 2016

0.1.6

0.1.6.0 https://github.com/webtoolsnz/yii2-validators

A collection of yii2 validators.

  Sources   Download

proprietary

The Requires

 

The Development Requires

yii2 validators

14/03 2016

0.1.5

0.1.5.0 https://github.com/webtoolsnz/yii2-validators

A collection of yii2 validators.

  Sources   Download

proprietary

The Requires

 

The Development Requires

yii2 validators

11/09 2015

0.1.3

0.1.3.0 https://github.com/webtoolsnz/yii2-validators

A collection of yii2 validators.

  Sources   Download

proprietary

The Requires

 

The Development Requires

yii2 validators

11/09 2015

0.1.4

0.1.4.0 https://github.com/webtoolsnz/yii2-validators

A collection of yii2 validators.

  Sources   Download

proprietary

The Requires

 

The Development Requires

yii2 validators

14/07 2015

0.1.2

0.1.2.0 https://github.com/webtoolsnz/yii2-validators

A collection of yii2 validators.

  Sources   Download

proprietary

The Requires

 

The Development Requires

yii2 validators

07/07 2015

0.1.1

0.1.1.0 https://github.com/webtoolsnz/yii2-validators

A collection of yii2 validators.

  Sources   Download

proprietary

The Requires

 

The Development Requires

yii2 validators