add changes to account state
This commit is contained in:
49
common/components/ArrayValidator.php
Normal file
49
common/components/ArrayValidator.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
namespace common\components;
|
||||
|
||||
use yii\base\InvalidConfigException;
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
|
||||
class ArrayValidator extends Validator
|
||||
{
|
||||
|
||||
public $arrayAttributeName;
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
if ($this->message === null) {
|
||||
$this->message = Yii::t('yii', '{attribute} is invalid.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function validateAttribute($model, $attribute)
|
||||
{
|
||||
$value = $model->$attribute;
|
||||
if (!is_array($value)) {
|
||||
$this->addError($model, $attribute, $this->message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function validateValue($value)
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
return [Yii::t('yii', '{attribute} is invalid.'), []];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user