PHP code example of thtmorais / yii2-validators

1. Go to this page and download the library: Download thtmorais/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/ */

    

thtmorais / yii2-validators example snippets




namespace app\models;

use thtmorais\validators\XandValidator;

/**
* Class Model
 */
class Model extends \yii\base\Model
{
    /**
    * @var string
    */
    public $google_client_id;
    
    /**
    * @var string
    */
    public $google_client_secret;
    
    /**
    * @var string
    */
    public $gitlab_client_id;
    
    /**
    * @var string
    */
    public $gitlab_client_secret;
    
    /**
    * @var string
    */
    public $gitlab_domain;;

    /**
    * {@inheritDoc}
     */
    public function rules()
    {
        return [
            [['google_client_id', 'google_client_secret'], XandValidator::class, 'fields' => ['google_client_id', 'google_client_secret']],
            [['gitlab_client_id', 'gitlab_client_secret', 'gitlab_domain'], XandValidator::class, 'fields' => ['gitlab_client_id', 'gitlab_client_secret', 'gitlab_domain']],
        ];
    }
}