<?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;
	}
	
	
}