thtmorais/yii2-validators

Validation suite for Yii PHP Framework 2

Installs: 93

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

0.0.1 2024-04-15 17:46 UTC

This package is auto-updated.

Last update: 2024-04-15 17:47:06 UTC


README

Installation

The preferred way to install this extension is through composer.

Either run

composer require thtmorais/yii2-validators "*"

or add

"thtmorais/yii2-validators": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by:

XandValidator

<?php

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']],
        ];
    }
}