yii\validators\Validator::validateAttribute PHP Метод

validateAttribute() публичный Метод

Child classes must implement this method to provide the actual validation logic.
public validateAttribute ( Model $model, string $attribute )
$model yii\base\Model the data model to be validated
$attribute string the name of the attribute to be validated.
    public function validateAttribute($model, $attribute)
    {
        $result = $this->validateValue($model->{$attribute});
        if (!empty($result)) {
            $this->addError($model, $attribute, $result[0], $result[1]);
        }
    }

Usage Example

Пример #1
0
 /**
  * @inheritdoc
  */
 public function validateAttribute($model, $attribute)
 {
     if ($this->range instanceof \Closure) {
         $this->range = call_user_func($this->range, $model, $attribute);
     }
     parent::validateAttribute($model, $attribute);
 }
All Usage Examples Of yii\validators\Validator::validateAttribute