PHP code example of webtoolsnz / yii2-validators

1. Go to this page and download the library: Download webtoolsnz/yii2-validators library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

webtoolsnz / yii2-validators example snippets


$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
        ' some error messages are also customizable
];

use webtoolsnz\validators\en_AU\NmiValidator;

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


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