{@inheritdoc}

@throws DcGeneralInvalidArgumentException When an empty parent model is given.
970155
public function getFilter($parent)
    {
        if (!$parent) {
            throw new DcGeneralInvalidArgumentException('No parent model passed.');
        }

        $result = [];
        foreach ($this->getFilterArray() as $child) {
            $result[] = $this->parseFilter($child, $parent);
        }

        return $result;
    }
597096
function Model(collectionName, attributes, values) {
    this.collectionName = collectionName;
    this.idAttribute = Model.getId(attributes);
    this.attributes = attributeValidator.validate(attributes);
    this.values = { };
    this.virtuals = { };

    // initially add the null value from all attributes
    for (var key in this.attributes) {
        this.values[key] = undefined;
    }

    // prevents from modifying values and adding properties
    Object.freeze(this.attributes);

    // prevents from adding new properties
    Object.seal(this.values);

    // sets the initial values
    this.set(values);
}
712013
@Override
    public void validate() throws OpsGenieClientValidationException {
        super.validate();
        if (id == null)
            throw OpsGenieClientValidationException.missingMandatoryProperty(OpsGenieClientConstants.API.ID);
    }
693876
protected void validatePluginDescriptor(PluginDescriptor descriptor) throws PluginException {
        if (StringUtils.isNullOrEmpty(descriptor.getPluginId())) {
            throw new PluginException("Field 'id' cannot be empty");
        }

        if (descriptor.getVersion() == null) {
            throw new PluginException("Field 'version' cannot be empty");
        }
    }
556350
public function setRoot(ModelInterface $model)
    {
        if (BasicDefinitionInterface::MODE_HIERARCHICAL !== $this->mode) {
            return;
        }

        $condition = $this->relationships->getRootCondition();
        if (!$condition instanceof RootConditionInterface) {
            throw new DcGeneralRuntimeException('No root condition defined');
        }

        $condition->applyTo($model);
    }
1228867
public function applyTo($objParent, $objChild)
    {
        $this->guardProviderNames($objChild, $objParent);

        $setters = $this->getSetters();

        if (empty($setters) || !\is_array($setters)) {
            throw new DcGeneralRuntimeException(
                \sprintf(
                    'No relationship setter defined from %s to %s.',
                    $this->getSourceName(),
                    $this->getDestinationName()
                )
            );
        }

        foreach ($setters as $setter) {
            if (!$this->isValidSetter($setter)) {
                throw new DcGeneralRuntimeException(
                    \sprintf(
                        'Invalid relationship setter entry, ensure it is an array containing only "to_field" and
                    one of "from_field", "value": %s',
                        \var_export($setter, true)
                    )
                );
            }

            if (isset($setter['from_field'])) {
                $objChild->setProperty($setter['to_field'], $objParent->getProperty($setter['from_field']));

                continue;
            }

            $objChild->setProperty($setter['to_field'], $setter['value']);
        }
    }
666977
protected function prepareModel()
    {
        if (!$this->model) {
            throw new MissingArgumentException('model property should be filled');
        }

        $this->model = new $this->model();

        $traits = class_uses_recursive(get_class($this->model));

        if (!isset($traits[Searchable::class])) {
            throw new InvalidArgumentException(get_class($this->model).' does not use the searchable trait');
        }
    }
1215556
public function createDcGeneral()
    {
        if (empty($this->containerName) && !$this->dataContainer) {
            throw new DcGeneralRuntimeException('Required container name or container is missing');
        }

        if (null === $this->eventDispatcher) {
            throw new DcGeneralRuntimeException('Required event dispatcher is missing');
        }

        // Backwards compatibility.
        $this->getEventDispatcher()->dispatch(PreCreateDcGeneralEvent::NAME, new PreCreateDcGeneralEvent($this));

        $environment = $this->environment ?: $this->createEnvironment();

        /** @var DcGeneral $dcGeneral */
        $dcGeneral = (new \ReflectionClass($this->dcGeneralClassName))->newInstance($environment);

        // Backwards compatibility.
        $this->getEventDispatcher()->dispatch(CreateDcGeneralEvent::NAME, new CreateDcGeneralEvent($dcGeneral));

        return $dcGeneral;
    }
1090190
public function validatePrimaryKey(EntityDefinition $entityMetadata)
    {
        // check if all tables have exactly one primary key
        $countPrimaryKeys = 0;

        foreach ($entityMetadata['table']['columns'] as $column) {
            if (! empty($column['primary'])) {
                $countPrimaryKeys++;
            }
        }

        if ($countPrimaryKeys == 0) {
            throw new DomainException('No primary key defined in class ' . $entityMetadata['class'] . '.');
        } elseif ($countPrimaryKeys > 1) {
            throw new DomainException('No composite primary keys allowed for class ' . $entityMetadata['class'] . '.');
        }
    }
672540
public static function makeXML($model, $parent, $addToParent = false)
    {
        if (is_array($model)) {
            foreach ($model as $name => $value) {
                if (!is_numeric($name)) {
                    $node = $parent->ownerDocument->createElement($name);
                    $parent->appendChild($node);
                    self::makeXml($value, $node, true);
                } else {
                    $node = $parent;
                    self::makeXml($value, $node);
                }
            }
        } elseif (is_object($model)) {
            if ($addToParent) {
                $node = $parent;
            } else {
                $node = $parent->ownerDocument->createElement(get_class($model));
                $parent->appendChild($node);
            }
            foreach ($model as $propertyName => $propertyValue) {
                $property = $parent->ownerDocument->createElement($propertyName);
                $node->appendChild($property);
                self::makeXml($propertyValue, $property);
            }
        } else {
            $parent->appendChild($parent->ownerDocument->createTextNode($model));
        }
    }
828875
protected function validateArray(&$document_data, &$data, array $data_pointer, array $parent_data_pointer, ISchema $document, $schema, ValidationResult $bag): bool
    {
        $ok = true;

        // minItems
        if (property_exists($schema, 'minItems')) {
            if (!is_int($schema->minItems)) {
                throw new SchemaKeywordException(
                    $schema,
                    'minItems',
                    $schema->minItems,
                    "'minItems' keyword must be an integer, " . gettype($schema->minItems) . " given"
                );
            }
            if ($schema->minItems < 0) {
                throw new SchemaKeywordException(
                    $schema,
                    'minItems',
                    $schema->minItems,
                    "'minItems' keyword must be positive, " . $schema->minItems . " given"
                );
            }
            if (($count = count($data)) < $schema->minItems) {
                $ok = false;
                $bag->addError(new ValidationError($data, $data_pointer, $parent_data_pointer, $schema, 'minItems', [
                    'min' => $schema->minItems,
                    'count' => $count,
                ]));
                if ($bag->isFull()) {
                    return false;
                }
            }
            unset($count);
        }

        // maxItems
        if (property_exists($schema, 'maxItems')) {
            if (!is_int($schema->maxItems)) {
                throw new SchemaKeywordException(
                    $schema,
                    'maxItems',
                    $schema->maxItems,
                    "'maxItems' keyword must be an integer, " . gettype($schema->maxItems) . " given"
                );
            }
            if ($schema->maxItems < 0) {
                throw new SchemaKeywordException(
                    $schema,
                    'maxItems',
                    $schema->maxItems,
                    "'maxItems' keyword must be positive, " . $schema->maxItems . " given"
                );
            }
            if (($count = count($data)) > $schema->maxItems) {
                $ok = false;
                $bag->addError(new ValidationError($data, $data_pointer, $parent_data_pointer, $schema, 'maxItems', [
                    'max' => $schema->maxItems,
                    'count' => $count,
                ]));
                if ($bag->isFull()) {
                    return false;
                }
            }
            unset($count);
        }

        // uniqueItems
        if (property_exists($schema, 'uniqueItems')) {
            if (!is_bool($schema->uniqueItems)) {
                throw new SchemaKeywordException(
                    $schema,
                    'uniqueItems',
                    $schema->uniqueItems,
                    "'uniqueItems' keyword must be a boolean, " . gettype($schema->uniqueItems) . " given"
                );
            }
            if ($schema->uniqueItems) {
                $valid = true;
                $count = count($data);
                $dup = null;
                for ($i = 0; $i < $count - 1; $i++) {
                    for ($j = $i + 1; $j < $count; $j++) {
                        if ($this->helper->equals($data[$i], $data[$j])) {
                            $valid = false;
                            $dup = $data[$i];
                            break 2;
                        }
                    }
                }
                if (!$valid) {
                    $ok = false;
                    $bag->addError(new ValidationError($data, $data_pointer, $parent_data_pointer, $schema, 'uniqueItems', [
                        'duplicate' => $dup,
                    ]));
                    if ($bag->isFull()) {
                        return false;
                    }
                }
                unset($valid, $count, $dup);
            }
        }

        // contains
        if (property_exists($schema, 'contains')) {
            $valid = false;
            $newbag = new ValidationResult(1);
            $errors = [];
            foreach ($data as $i => &$value) {
                $data_pointer[] = $i;
                $valid = $this->validateSchema($document_data, $value, $data_pointer, $parent_data_pointer, $document, $schema->contains, $newbag);
                array_pop($data_pointer);
                if ($valid) {
                    break;
                }
                $errors = array_merge($errors, $newbag->getErrors());
                $newbag->clear();
            }
            unset($value, $newbag);
            if (!$valid) {
                $ok = false;
                $bag->addError(new ValidationError($data, $data_pointer, $parent_data_pointer, $schema, 'contains', [], $errors));
                if ($bag->isFull()) {
                    return false;
                }
            }
            unset($valid, $errors);
        }

        // items, additionalItems
        if (property_exists($schema, 'items')) {
            if (is_array($schema->items)) {
                $count = count($schema->items);
                $data_count = count($data);
                $max = min($count, $data_count);
                for ($i = 0; $i < $max; $i++) {
                    $data_pointer[] = $i;
                    $valid = $this->validateSchema($document_data, $data[$i], $data_pointer, $parent_data_pointer, $document, $schema->items[$i], $bag);
                    array_pop($data_pointer);
                    if (!$valid) {
                        $ok = false;
                        if ($bag->isFull()) {
                            return false;
                        }
                    }
                }
                if ($max < $data_count && property_exists($schema, 'additionalItems')) {
                    if (!is_bool($schema->additionalItems) && !is_object($schema->additionalItems)) {
                        throw new SchemaKeywordException(
                            $schema,
                            'additionalItems',
                            $schema->additionalItems,
                            "'additionalItems' keyword must be a boolean or an object, " . gettype($schema->additionalItems) . " given"
                        );
                    }
                    for ($i = $max; $i < $data_count; $i++) {
                        $data_pointer[] = $i;
                        $valid = $this->validateSchema($document_data, $data[$i], $data_pointer, $parent_data_pointer, $document, $schema->additionalItems, $bag);
                        array_pop($data_pointer);
                        if (!$valid) {
                            $ok = false;
                            if ($bag->isFull()) {
                                return false;
                            }
                        }
                    }
                }
                unset($max, $count, $data_count);
            } else {
                $count = count($data);
                for ($i = 0; $i < $count; $i++) {
                    $data_pointer[] = $i;
                    $valid = $this->validateSchema($document_data, $data[$i], $data_pointer, $parent_data_pointer, $document, $schema->items, $bag);
                    array_pop($data_pointer);
                    if (!$valid) {
                        $ok = false;
                        if ($bag->isFull()) {
                            return false;
                        }
                    }
                }
            }
        }

        return $ok;
    }
1197340
public function setCondition($condition)
    {
        if ((!$condition instanceof PaletteConditionInterface)
            && (!$condition instanceof PropertyConditionInterface)
        ) {
            throw new DcGeneralInvalidArgumentException(
                'The condition is invalid. ' .
                ' Only use PaletteConditionInterface or PropertyConditionInterface.'
            );
        }

        $this->condition = $condition;

        return $this;
    }
1188840
public function generateDetailsPrimaryKey(& $holder, $type = 'reset', $values = null, $parent_keys = null, $options = []) {
		// generate holder
		if ($type == 'reset') {
			$collection = [];
			if (!empty($this->collection_object)) {
				$collection = array_key_get($this->collection_object->data, $options['options']['details_collection_key']);
			}
			$holder = [
				'collection' => $collection,
				'parent_pks' => [],
				'new_pk_counter' => 1,
				'new_pk_locks' => [],
				'error_name' => null,
				'pk' => null
			];
			// populate parent pks
			if (!empty($holder['collection'])) {
				foreach ($holder['collection']['map'] as $k12 => $v12) {
					if (isset($values[$k12])) {
						$holder['parent_pks'][$v12] = $values[$k12];
					}
				}
			}
		}
		// generate new pk
		if ($type == 'pk') {
			// if we have no collection we accept values as they are
			$new_pk = [];
			if (!empty($holder['collection'])) {
				foreach ($holder['collection']['pk'] as $v) {
					if (isset($holder['parent_pks'][$v])) {
						$new_pk[] = $holder['parent_pks'][$v];
					} else if (!empty($values[$v])) {
						$new_pk[] = $values[$v];
					} else {
						$new_pk[] = '__new_key_' . $holder['new_pk_counter'];
						$holder['new_pk_counter']++;
					}
				}
			} else if (!empty($options['options']['details_pk'])) {
				foreach ($options['options']['details_pk'] as $v) {
					if (isset($values[$v])) {
						$new_pk[] = $values[$v];
					}
				}
			} else {
				$new_pk[] = current($values);
			}
			$holder['pk'] = implode('::', $new_pk);
			if (!empty($holder['new_pk_locks'][$holder['pk']])) {
				// error only if we have pk
				if (!empty($holder['pk'])) {
					$holder['pk'] = '__duplicate_key_' . $holder['new_pk_counter'];
					$holder['new_pk_counter']++;
					$error_pk = !empty($options['options']['details_11']) ? ($parent_keys ?? []) : array_merge($parent_keys ?? [], [$holder['pk']]);
					$holder['error_name'] = $this->parentKeysToErrorName($error_pk);
					foreach ($options['options']['details_pk'] as $v) {
						$this->error('danger', \Object\Content\Messages::DUPLICATE_VALUE, "{$holder['error_name']}[{$v}]");
					}
				}
			} else {
				$error_pk = !empty($options['options']['details_11']) ? ($parent_keys ?? []) : array_merge($parent_keys ?? [], [$holder['pk']]);
				$holder['error_name'] = $this->parentKeysToErrorName($error_pk);
				$holder['new_pk_locks'][$holder['pk']] = true;
			}
		}
	}
979370
public function validateImplementation()
	{
		$required = [
			'model'         => ' does not implement a model definition.',
			'resource_path' => ' does not implement a resource path definition.',
		];

		foreach ($required as $implementation => $message) {
			if (! isset($this->{$implementation})) {
				throw new \InvalidArgumentException(static::class . $message);
			}
		}
	}
1292712
protected function validate_parentid($value) {

        // Check that the parent exists. But only if we don't have it already, and we actually have a parent.
        if (!empty($value) && !$this->newparent && !self::record_exists($value)) {
            return new lang_string('invaliddata', 'error');
        }

        // During update.
        if ($this->get('id')) {

            // If there is a new parent.
            if ($this->beforeupdate->get('parentid') != $value && $this->newparent) {

                // Check that the new parent belongs to the same framework.
                if ($this->newparent->get('competencyframeworkid') != $this->get('competencyframeworkid')) {
                    return new lang_string('invaliddata', 'error');
                }
            }
        }

        return true;
    }
874143
public function readFromPropertyValueBag(PropertyValueBagInterface $valueBag)
    {
        foreach (\array_keys($this->arrProperties) as $name) {
            if (!$valueBag->hasPropertyValue($name)) {
                continue;
            }

            if ($valueBag->isPropertyValueInvalid($name)) {
                throw new DcGeneralInvalidArgumentException('The value for property ' . $name . ' is invalid.');
            }

            $this->setProperty($name, $valueBag->getPropertyValue($name));
        }

        return $this;
    }
179160
private function validateChildClass(NodeInterface $parentNode, ClassMetadata $class)
    {
        $parentClass = $this->documentClassMapper->getClassName($this->dm, $parentNode);

        if (null === $parentClass) {
            return;
        }

        $metadata = $this->dm->getClassMetadata($parentClass);
        $metadata->assertValidChildClass($class);
    }