Removes errors for all attributes or a single attribute.

@param null $attribute
9768
public function clearErrors($attribute = null)
    {
        if ($attribute === null) {
            $this->errors = [];
        } else {
            unset($this->errors[$attribute]);
        }
    }
731120
public function onerror($attributes) {

        if(false === is_array($attributes)) {
            return trigger_error(sprintf('Argument 1 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($attributes)), E_USER_ERROR);
        }

        if(true === isset($this -> attributes['name'])) {

            $helper = new StringToArray();
            $data   = $helper -> execute($this -> attributes['name'], null, MessageFile :: getErrors(true));
            $data   = $helper -> execute($this -> attributes['name'], null, MessageForm :: getErrors(true));

            if(null !== $data) {
                $this -> attributes = array_merge($this -> attributes, $attributes);
            }
        }

        return $this;
    }
300284
protected function validateAttribute($object, $attribute)
    {
        $value = $object->{$attribute};
        if ($this->isEmpty($value)) {
            $this->validateEmpty($object, $attribute);
            return;
        }
        if (
            (!$this->strict && $value != $this->trueValue && $value != $this->falseValue)
            || ($this->strict && $value !== $this->trueValue && $value !== $this->falseValue)
        ) {
            $this->addError($object, $attribute, $this->message, [
                '{true}' => $this->trueValue,
                '{false}' => $this->falseValue,
            ]);
        }
    }
218636
public function first($attribute=null) {
		if($attribute !== null)
			return $this->attribute($attribute)->first();
		else {
			if($this->rules)
				return array_values($this->rules)[0];
			elseif($this->attributes)
				return array_values($this->attributes)[0]->error();
		}
	}
1337419
protected function checkAttributeAssignable($attribute): void
    {
        if (empty($this->assignable)) {
            return;
        }

        if (is_array($attribute)) {

            foreach ($attribute as $singleAttribute) {
                $this->checkAttributeAssignable($singleAttribute);
            }

            return;
        }

        if ( ! in_array($attribute, $this->assignable)) {
            throw new UnassignableAttributeException("Not allowed to assign value for '{$attribute}'");
        }
    }
544918
public function validationErrors($attributes, $rules = null)
    {

        // Rules container
        $this->rules = $this->setValidationRules();

        // Ruleset
        $ruleSet = isset($rules)? $rules : $this->validate;

        // Errors collector
        $errors = [];

        // Leave only the validable attributes
        $attributes = array_intersect_key($attributes, array_flip(array_keys($ruleSet)));

        // Check for required attributes
        foreach ($ruleSet as $key => $rules) {
            if (in_array('required', $rules) && (!isset($attributes[$key]) || trim($attributes[$key]) === '')) {
                $errors[$key] = 'required';
            }
            $ruleSet[$key] = array_diff($rules, ['required']);
        }

        // Check for format errors
        foreach ($attributes as $key => $value) {
            foreach ($ruleSet[$key] as $name => $rule) {
                if (!preg_match($this->rules[$rule], $value)) {
                    $errors[$key] = $rule;
                }
            }
        }

        // Return errors or false
        return count($errors)? $errors : false;
    }
138463
public function removeAttribute(Attribute $attribute)
    {
        foreach ($this->attributes as $key => $attributeElement) {
            if ($attributeElement === $attribute) {
                unset($this->attributes[$key]);
                break;
            }
        }

        return $this;
    }
467398
public function hasErrors($attribute = null)
    {
        if (!count($this->_errors)) {
            return false;
        }
        if ($attribute && isset($this->_errors[$attribute]) && count($this->_errors[$attribute])) {
            return true;
        } elseif ($attribute) {
            return false;
        }
        return true;
    }
183794
public static function allAttributesFrom(string $attribute) {
		$modules = self::all();
		$result = [];
		foreach ($modules as $module) {
			if ($module->$attribute) {
				$attr = $module->$attribute;
				
				if (is_array($attr)) {
					foreach ($attr as $item) {
						$result[] = $item;
					}
				}
				else {
					$result[] = $attr;
				}
			}
		}
		
		return empty($result) ? null : $result;
	}
229011
protected function passesOptionalCheck($attribute)
    {
        if (! $this->hasRule($attribute, ['Sometimes'])) {
            return true;
        }

        $data = ValidationData::initializeAndGatherData($attribute, $this->data);

        return array_key_exists($attribute, $data)
            || array_key_exists($attribute, $this->data);
    }
391490
public function getFirstError($attribute = null)
    {
        if (empty($this->errors)) {
            return null;
        }
        if (isset($attribute)) {
            if (isset($this->errors[$attribute])) {
                return current($this->errors[$attribute]);
            }
            return null;
        }
        $error = current($this->errors);
        if (is_array($error)) {
            return current($error);
        }
        return $error;
    }
768092
public function isFirstErrorAttribute($attribute) {
		if($this->_firstErrorAttribute === false) {
			$errorAttributes = array_keys($this->firstErrors);
			$this->_firstErrorAttribute = array_shift($errorAttributes);
		}

		return $attribute == $this->_firstErrorAttribute;
	}
60434
public function validateAttribute($model, $attribute)
    {
        $value = $model->$attribute;
        $result = $this->validateValue($value);

        if (!empty($result)) {
            $this->addError($model, $attribute, $this->renderMessage($model, $attribute));
        }
    }
547553
function resetChangeHistory($attribute) {
    if ($this->propertyExists($attribute, 'changes')) {
        $this->setPropertyFor($attribute, 'changes', [], null, false);
    }

    return $this;
  }
697285
public function validateCommand ($attribute)
		{
			if (!$this->hasErrors())
			{
				$return_var1 = $return_var2 = $return_var3 = 0;
				exec('command -v ' . $this->$attribute . '', $output, $return_var);
				if ($return_var == 127)
					$this->addError($attribute, Yii::tr('Command not found.', [], 'setting'));
			}
		}
121874
protected function addError($attribute, $message)
    {
        if (!isset($this->errors[$attribute])) {
            $this->errors[$attribute] = array();
        }
        $this->errors[$attribute][] = $message;
    }
214758
public function emptyValues(AttributeInterface $attribute = null, array $context = null)
    {
        $values = $this->getInternalValues($attribute, $context);
        foreach ($values as $value) {
            $this->removeValue($value);
        }

        return $this;
    }