Validate the version table.

@param \ProAI\Datamapper\Metadata\Definitions\Entity $entityMetadata
@return void
504083
public function validateVersionTable(EntityDefinition $entityMetadata)
    {
        $columnNames = [];
        $countPrimaryKeys = 0;
        $versionPrimaryKey = false;

        // get column names
        foreach ($entityMetadata['table']['columns'] as $column) {
            $columnNames[] = $column['name'];
        }

        if (! in_array('latest_version', $columnNames)) {
            throw new DomainException('@Versionable annotation defined in class ' . $entityMetadata['class'] . ' requires a $latestVersion column property.');
        }

        $columnNames = [];

        // get version column names
        foreach ($entityMetadata['versionTable']['columns'] as $column) {
            $columnNames[] = $column['name'];
            if (! empty($column['primary'])) {
                $countPrimaryKeys++;
            }
            if (! empty($column['primary']) && $column['name'] == 'version') {
                $versionPrimaryKey = true;
            }
        }

        if (! in_array('version', $columnNames) || ! $versionPrimaryKey) {
            throw new DomainException('@Versionable annotation defined in class ' . $entityMetadata['class'] . ' requires a $version property column, which is a primary key.');
        }
        if ($countPrimaryKeys > 2) {
            throw new DomainException('No more than 2 primary keys are allowed for version table in class ' . $entityMetadata['class'] . '.');
        }
    }
1173885
public function validate($entity, Constraint $constraint): void
    {
        /** @var HasEnabledEntity $constraint */
        Assert::isInstanceOf($constraint, HasEnabledEntity::class);

        $enabled = $this->accessor->getValue($entity, $constraint->enabledPath);

        if ($enabled === true) {
            return;
        }

        $objectManager = $this->getProperObjectManager($constraint->objectManager, $entity);

        $this->ensureEntityHasProvidedEnabledField($objectManager, $entity, $constraint->enabledPath);

        $criteria = [$constraint->enabledPath => true];

        $repository = $objectManager->getRepository(get_class($entity));
        $results = $repository->{$constraint->repositoryMethod}($criteria);

        /* If the result is a MongoCursor, it must be advanced to the first
         * element. Rewinding should have no ill effect if $result is another
         * iterator implementation.
         */
        if ($results instanceof \Iterator) {
            $results->rewind();
        } elseif (is_array($results)) {
            reset($results);
        }

        if ($this->isLastEnabledEntity($results, $entity)) {
            $errorPath = null !== $constraint->errorPath ? $constraint->errorPath : $constraint->enabledPath;

            $this->context->buildViolation($constraint->message)->atPath($errorPath)->addViolation();
        }
    }
564620
public function ensureMetaDataIsSet(EntityManagerInterface $entityManager): void
    {
        self::getDoctrineStaticMeta()->setMetaData($entityManager->getClassMetadata(self::class));
    }
215096
protected String checkForMariaDb(DatabaseMetaData databaseMetaData, String databaseName) {
    try {
      String databaseProductVersion = databaseMetaData.getDatabaseProductVersion();
      if (databaseProductVersion != null && databaseProductVersion.toLowerCase().contains("mariadb")) {
        return MARIA_DB_PRODUCT_NAME;
      }
    } catch (SQLException ignore) {
    }

    try {
      String driverName = databaseMetaData.getDriverName();
      if (driverName != null && driverName.toLowerCase().contains("mariadb")) {
        return MARIA_DB_PRODUCT_NAME;
      }
    } catch (SQLException ignore) {
    }

    String metaDataClassName = databaseMetaData.getClass().getName();
    if (metaDataClassName != null && metaDataClassName.toLowerCase().contains("mariadb")) {
      return MARIA_DB_PRODUCT_NAME;
    }

    return databaseName;
  }
920606
public function renderVersion(array $versionData = []) : void
    {
        if ($this->isSilent()) {
            return;
        }

        $this->logger->debug('rendering version information');

        fwrite($this->file, '<gjk_browscap_version>' . PHP_EOL);

        if (!isset($versionData['version'])) {
            $versionData['version'] = '0';
        }

        if (!isset($versionData['released'])) {
            $versionData['released'] = '';
        }

        fwrite($this->file, '<item name="Version" value="' . $this->formatter->formatPropertyName($versionData['version']) . '"/>' . PHP_EOL);
        fwrite($this->file, '<item name="Released" value="' . $this->formatter->formatPropertyName($versionData['released']) . '"/>' . PHP_EOL);

        fwrite($this->file, '</gjk_browscap_version>' . PHP_EOL);
    }
832889
private function freshOrNull(ClassMetadata $classMetadata = null)
    {
        if (null === $classMetadata) {
            return;
        }

        return $this->freshnessValidator->isFresh($classMetadata) ? $classMetadata : null;
    }
881186
public function validateMetadata($requestedType, EntityMetadata $metadata, MetadataFactory $mf)
    {
        if ($requestedType !== $metadata->type) {
            throw MetadataException::invalidMetadata($requestedType, 'Metadata type mismatch.');
        }
        $this->validateMetadataType($metadata);

        if (null === $metadata->persistence) {
            throw MetadataException::invalidMetadata($requestedType, 'No persistence metadata was found. All models must use a persistence layer.');
        }

        $this->validateMetadataInheritance($metadata, $mf);
        $this->validateMetadataAttributes($metadata, $mf);
        $this->validateMetadataRelationships($metadata, $mf);
        $this->validateMetadataEmbeds($metadata, $mf);
        return true;
    }
927444
public function update(Entity $entity, $primaryValue)
    {
        if (!$entity->getValidator()->validate()) {
            throw new Exception\ValidatorException($entity->getValidator());
        }

        try {

            if (!$this->query()->updateOne($primaryValue, $entity->getData())->run($this->connection)) {
                throw new Exception\RepositoryException("Entity was not successfully updated!");
            }
        } catch (Exception\QueryException $e) {
            throw new Exception\RepositoryException($e->getMessage());
        }

        $this->_saveAssociated($primaryValue, $entity);
    }
1182274
public void validate(EntityType entityType) {
    validateEntityId(entityType);
    validateEntityLabel(entityType);
    validatePackage(entityType);
    validateExtends(entityType);
    validateOwnAttributes(entityType);

    Map<String, Attribute> ownAllAttrMap =
        stream(entityType.getOwnAllAttributes())
            .collect(toLinkedMap(Attribute::getIdentifier, Function.identity()));

    validateOwnIdAttribute(entityType, ownAllAttrMap);
    validateOwnLabelAttribute(entityType, ownAllAttrMap);
    validateOwnLookupAttributes(entityType, ownAllAttrMap);
    validateLabelAttribute(entityType);
    validateBackend(entityType);
  }
1307418
public void validate(CFMetaData metadata) {
        for (Map.Entry<String, ColumnMapper> entry : columnMappers.entrySet()) {

            String name = entry.getKey();
            ColumnMapper columnMapper = entry.getValue();
            ByteBuffer columnName = UTF8Type.instance.decompose(name);

            ColumnDefinition columnDefinition = metadata.getColumnDefinition(columnName);
            if (columnDefinition == null) {
                throw new RuntimeException("No column definition for mapper " + name);
            }

            if (columnDefinition.isStatic()) {
                throw new RuntimeException("Lucene indexes are not allowed on static columns as " + name);
            }

            AbstractType<?> type = columnDefinition.type;
            if (!columnMapper.supports(type)) {
                throw new RuntimeException(String.format("Type '%s' is not supported by mapper '%s'", type, name));
            }
        }
    }
81917
public function validate()
    {
        if (!$this->migrationsDatabaseName) {
            $message = 'Migrations Database Name must be configured in order to use AntiMattr migrations.';
            throw new ConfigurationValidationException($message);
        }
        if (!$this->migrationsNamespace) {
            $message = 'Migrations namespace must be configured in order to use AntiMattr migrations.';
            throw new ConfigurationValidationException($message);
        }
        if (!$this->migrationsDirectory) {
            $message = 'Migrations directory must be configured in order to use AntiMattr migrations.';
            throw new ConfigurationValidationException($message);
        }
    }
730904
private static void verifyId(final EntityMetadata entityMetadata) {
        if (!entityMetadata.hasIdProperty()) {
            throw new RepositoryMappingException("No field annotated with @Id present.");
        }

        if (entityMetadata.idProperty().type() != String.class) {
            throw new RepositoryMappingException("The @Id Field needs to be of type String.");
        }
    }
1223148
public function handleVersionAnnotation($e)
    {
        $annotation = $e->getParam('annotation');
        if (!$annotation instanceof Annotation\Version) {
            return;
        }
    
        $serviceSpec = $e->getParam('serviceSpec');
        $serviceSpec['version'] = $annotation->getVersion();
    }
533748
private function validateVersion()
    {
        $this->blacklistCheck($this->version);
        if (!empty($this->version) &&
            (
                str_replace('+', '', filter_var($this->version, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)) !== $this->version ||
                version_compare($this->version, '0.0.1', '>=') === false
            )
        ) {
            throw new Exceptions\VersionException("Invalid version format (`$this->version`). See http://semver.org/ for guidelines. In addition, dev/alpha/beta/rc tags is disallowed. See also " . self::RFC_README);
        }
        $this->version = trim($this->version, '.0');
        return true;
    }
597223
private static void validateEntity(Entity entity) throws DbRuntimeException {
		if (null == entity) {
			throw new DbRuntimeException("Entity is null !");
		}
		if (StrUtil.isBlank(entity.getTableName())) {
			throw new DbRuntimeException("Entity`s table name is null !");
		}
		if (entity.isEmpty()) {
			throw new DbRuntimeException("No filed and value in this entity !");
		}
	}
440505
public boolean validate(E entity)
    {
        if (entity != null)
        {
            // entity metadata could be null.
            if (entityMetadata == null)
            {
                throw new IllegalArgumentException(
                        "Entity object is invalid, operation failed. Please check previous log message for details");
            }

            return false;

        }

        // will return false if entity is null.
        return true;
    }
1225967
def validate(self):
        
        try:
            Configuration(**self.serialize())
        except ValidationException as e:
            raise DbtProjectError(str(e))

        if getattr(self.args, 'version_check', False):
            self.validate_version()