thtmorais/yii2-validators

为 Yii PHP 框架 2 的验证工具包

安装: 626

依赖者: 0

建议者: 0

安全: 0

星标: 2

关注者: 1

分支: 0

开放问题: 0

类型:yii2-extension

0.0.1 2024-04-15 17:46 UTC

This package is auto-updated.

Last update: 2024-09-15 18:38:21 UTC


README

安装

安装此扩展的首选方法是使用 composer

运行以下命令之一:

composer require thtmorais/yii2-validators "*"

或者将以下内容添加到您的 composer.json 文件的 require 部分:

"thtmorais/yii2-validators": "*"

to the require section of your composer.json file.

使用方法

扩展安装后,只需在代码中使用即可:

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