PHP code example of nsu-soft / yii-validation-inn

1. Go to this page and download the library: Download nsu-soft/yii-validation-inn 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/ */

    

nsu-soft / yii-validation-inn example snippets




namespace app\forms;

use nsusoft\validators\InnValidator;
use yii\base\Model;

class InnForm extends Model
{
    public string $inn;
    
    /**
     * @inheritDoc
     */
    public function rules(): array
    {
        return [
            [['inn'], InnValidator::class],
        ];
    }

    /**
     * @return bool
     */
    public function save(): bool
    {
        if (!$this->validate()) {
            return false;
        }
        
        // other form logic
        
        return true; 
    }
}

[['inn'], InnValidator::class, 'type' => InnValidator::TYPE_INDIVIDUAL]

[['inn'], InnValidator::class, 'type' => InnValidator::TYPE_LEGAL]