Throw an exception if a model is not valid.

@param array $attributes
492797
public function assertValid(array $attributes)
    {
        $validator = $this->makeValidator($attributes);

        if ($validator->fails()) {
            throw new ValidationException($validator);
        }
    }
1041229
private function validateAttributes(iterable $attributes): self
    {
        // execute start(s)
        $this->executeStarts($this->getSerializer()::readRuleStartIndexes($this->getRuleIndexes()));

        foreach ($attributes as $name => $value) {
            if (($index = $this->getAttributeIndex($name)) !== null) {
                $this->executeBlock($value, $index);
            } else {
                $this->getErrorAggregator()->add(
                    new Error($name, $value, ErrorCodes::INVALID_VALUE, Messages::INVALID_VALUE, [])
                );
            }
        }

        // execute end(s)
        $this->executeEnds($this->getSerializer()::readRuleEndIndexes($this->getRuleIndexes()));

        return $this;
    }
552844
protected function validateAttribute (string $attribute=NULL) : bool
	{
		if (!property_exists($this, $attribute))
		{
			$this->error = "Attribute: ".ucfirst($attribute)." is not a class object.";
        	return FALSE;
		}
        $result = (is_array($this->$attribute)) ? !empty($this->$attribute) : Validate::hasValue($this->$attribute);
        if ($result) return TRUE;
		$this->error = "Set ".ucfirst($attribute)." to log your message.";
    	return FALSE;
	}
688106
public function setAttributes($attributes)
    {
        if (! is_array($attributes)) {
            $attributes = [$attributes];
        }

        $this->attributes = $attributes;

        return $this;
    }
837863
final public function sort(array $attributes = array())
    {
        $product        = $this->find($attributes['movingId']);
        $positionEntity = $this->find($attributes['movedId']);

        if ($product instanceof Product) {
            if ($this->fireEvent('sorting', array($product)) === false) {
                return false;
            }

            $product->setCaller($this);
            $product->{$attributes['type']}($positionEntity);

            $this->fireEvent('sorted', array($product));

            return $product;
        }

        throw new Exception(sprintf(Exception::CANT_UPDATE_MODEL,
            'Subbly\\Model\\Product',
            $this->name()
        ));
    }
381350
private function validateUserInputs($attributes, $eventTags = null)
    {
        if (!is_null($attributes) && !Validator::areAttributesValid($attributes)) {
            $this->_logger->log(Logger::ERROR, 'Provided attributes are in an invalid format.');
            $this->_errorHandler->handleError(
                new InvalidAttributeException('Provided attributes are in an invalid format.')
            );
            return false;
        }

        if (!is_null($eventTags)) {
            if (!Validator::areEventTagsValid($eventTags)) {
                $this->_logger->log(Logger::ERROR, 'Provided event tags are in an invalid format.');
                $this->_errorHandler->handleError(
                    new InvalidEventTagException('Provided event tags are in an invalid format.')
                );
                return false;
            }
        }

        return true;
    }
725085
public function validate()
    {
        $attributes = static::getMapper()->getAttributes();
        $keys = $this->isFresh() ? array_keys($attributes) : array_keys($this->dirty);

        foreach ($keys as $key) {
            $attribute = $attributes[$key];

            if ($attribute['auto_generate'] && $this->isFresh()) {
                continue;
            }

            $value = $this->get($key);
            $type = Type::factory($attribute['type']);

            if ($type->isNull($value)) {
                if (!$attribute['allow_null']) {
                    throw new Exception\UnexpectedPropertyValueException(sprintf('%s: Property "%s", not allow null', get_class($this), $key));
                }
            } else {
                if ($attribute['regexp'] && !preg_match($attribute['regexp'], $value)) {
                    throw new Exception\UnexpectedPropertyValueException(sprintf('%s: Property "%s", mismatching pattern %s', get_class($this), $key, $attribute['regexp']));
                }

                if (!$attribute['allow_tags'] && is_string($value) && \Owl\str_has_tags($value)) {
                    throw new Exception\UnexpectedPropertyValueException(sprintf('%s: Property "%s", cannot contain tags', get_class($this), $key));
                }

                try {
                    $type->validateValue($value, $attribute);
                } catch (\Exception $ex) {
                    $message = sprintf('%s: Property "%s", %s', get_class($this), $key, $ex->getMessage());
                    throw new Exception\UnexpectedPropertyValueException($message, 0, $ex);
                }
            }
        }

        return true;
    }
509225
protected function attribute(&$attributes) {
        $tok = $this->scanner->current();
        if ($tok == '/' || $tok == '>' || $tok === false) {
            return false;
        }

        if ($tok == '<') {
            $this->parseError("Unexepcted '<' inside of attributes list.");
            // Push the < back onto the stack.
            $this->scanner->unconsume();
            // Let the caller figure out how to handle this.
            throw new HTML5_Parser_Exception("Start tag inside of attribute.");
        }

        $name = strtolower($this->scanner->charsUntil("/>=\n\f\t "));

        if (strlen($name) == 0) {
            $this->parseError("Expected an attribute name, got %s.", $this->scanner->current());
            // Really, only '=' can be the char here. Everything else gets absorbed
            // under one rule or another.
            $name = $this->scanner->current();
            $this->scanner->next();
        }

        $isValidAttribute = true;
        // Attribute names can contain most Unicode characters for HTML5.
        // But method "DOMElement::setAttribute" is throwing exception
        // because of it's own internal restriction so these have to be filtered.
        // see issue #23: https://github.com/Masterminds/html5-php/issues/23
        // and http://www.w3.org/TR/2011/WD-html5-20110525/syntax.html#syntax-attribute-name
        if (preg_match("/[\x1-\x2C\\/\x3B-\x40\x5B-\x5E\x60\x7B-\x7F]/u", $name)) {
            $this->parseError("Unexpected characters in attribute name: %s", $name);
            $isValidAttribute = false;
        }         // There is no limitation for 1st character in HTML5.
        // But method "DOMElement::setAttribute" is throwing exception for the
        // characters below so they have to be filtered.
        // see issue #23: https://github.com/Masterminds/html5-php/issues/23
        // and http://www.w3.org/TR/2011/WD-html5-20110525/syntax.html#syntax-attribute-name
        else
        if (preg_match("/^[0-9.-]/u", $name)) {
            $this->parseError("Unexpected character at the begining of attribute name: %s", $name);
            $isValidAttribute = false;
        }
        // 8.1.2.3
        $this->scanner->whitespace();

        $val = $this->attributeValue();
        if ($isValidAttribute) {
            $attributes[$name] = $val;
        }
        return true;
    }
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}'");
        }
    }
1290389
protected function validateAttributesToLdap(array $attributes)
    {
        if (!$this->schema) {
            return;
        }
        $missing = [];

        foreach ($this->schema->getRequiredAttributes() as $attribute) {
            if (!array_key_exists(strtolower($attribute), array_change_key_case($attributes))) {
                $missing[] = $attribute;
            }
        }

        if (!empty($missing)) {
            throw new LogicException(
                sprintf('The following required attributes are missing: %s', implode(', ', $missing))
            );
        }
    }
481044
public function validateAttribute($model, $attribute)
    {
        if (
            $this->targetClass !== null
            && $model->$attribute instanceof $this->targetClass
            && !empty($model->$attribute->isNewRecord)
        ) {
            return;
        }

        if ($model->isRelationPopulated($attribute)) {
            return;
        }

        parent::validateAttribute($model, $attribute);
    }
822203
public function validate(array $attributes)
    {
        $table     = $this->model->getTable();
        $locale    = array_get($attributes, 'locale', '');
        $namespace = array_get($attributes, 'namespace', '');
        $group     = array_get($attributes, 'group', '');
        $rules     = [
            'locale'    => 'required',
            'namespace' => 'required',
            'group'     => 'required',
            'item'      => "required|unique:{$table},item,NULL,id,locale,{$locale},namespace,{$namespace},group,{$group}",
            'text'      => '', // Translations may be empty
        ];
        $validator = $this->app['validator']->make($attributes, $rules);
        if ($validator->fails()) {
            $this->errors = $validator->errors();
            return false;
        }
        return true;
    }
987318
public function toManage($models, array $attributes = [])
    {
        if (is_array($models)) {
            foreach ($models as $model) {
                $this->to('*', $model, $attributes);
            }
        } else {
            $this->to('*', $models, $attributes);
        }
    }
831585
public function containsAttributes(array $attributes)
    {
        foreach ($attributes as $attribute) {
            if (!$this->attributes->contains($attribute)) {
                return false;
            }
        }

        return true;
    }
542379
final public function sort(array $attributes = array())
    {
        $category       = $this->find($attributes['movingId']);
        $positionEntity = $this->find($attributes['movedId']);

        if ($category instanceof Category) {
            if ($this->fireEvent('sorting', array($category)) === false) {
                return false;
            }

            $category->setCaller($this);
            $category->{$attributes['type']}($positionEntity);

            $this->fireEvent('sorted', array($category));

            return $category;
        }

        throw new Exception(sprintf(Exception::CANT_UPDATE_MODEL,
            'Subbly\\Model\\Category',
            $this->name()
        ));
    }
382363
public function validate(array $fields)
    {
        $this->flashInput($fields);

        $rules = $this->getValidationRules($fields);

        $validator = $this->getValidatorInstance($rules);

        if($validator->fails()){

            $this->failedValidation($validator);
        }
    }
587805
public function AddErrorClass(&$Attributes) {
      if (isset($Attributes['class']))
         $Attributes['class'] .= ' '.$this->ErrorClass;
      else
         $Attributes['class'] = $this->ErrorClass;
   }