Check any type

@param mixed $entity
@param object $schema
@param string $entityName

@return Validator
424564
protected function checkTypeAny($entity, $schema, $entityName)
    {
        $this->checkDisallow($entity, $schema, $entityName);

        return $this;
    }
348896
@Override
    public boolean validateEntity(Class clazz)
    {
        EntityValidatorAgainstCounterColumn entityValidatorAgainstSchema = new EntityValidatorAgainstCounterColumn();
        return entityValidatorAgainstSchema.validateEntity(clazz);
    }
1157048
function checkEntityTypes(em, entityTypes) {
    assertParam(entityTypes, "entityTypes").isString().isOptional().or().isNonEmptyArray().isString()
        .or().isInstanceOf(EntityType).or().isNonEmptyArray().isInstanceOf(EntityType).check();
    if (typeof entityTypes === "string") {
      entityTypes = em.metadataStore._getEntityType(entityTypes, false);
    } else if (Array.isArray(entityTypes) && typeof entityTypes[0] === "string") {
      entityTypes = entityTypes.map(function (etName) {
        return em.metadataStore._getEntityType(etName, false);
      });
    }
    return entityTypes;
  }
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);
  }
1306929
protected function validateObjectSchema($schema)
    {
        if (empty($schema->getAttributeMap())) {
            throw new SchemaParserException(sprintf('Object type "%s" has no attributes defined.', $schema->getObjectType()));
        } elseif (!((bool)count(array_filter(array_keys($schema->getAttributeMap()), 'is_string')))) {
            throw new SchemaParserException('The attributes for a schema should be an associative array.');
        }
        
        if ($schema->getScope() && !in_array($schema->getScope(), QueryOperation::SCOPE)) {
            throw new SchemaParserException(sprintf(
                'The scope "%s" is not valid. Valid types are: %s',
                $schema->getScope(),
                implode(', ', QueryOperation::SCOPE)
            ));
        }
    }
1345472
protected function parseToDocument($entity)
    {
        $schemaMapper = $this->getSchemaMapper();
        $parsedDocument = $schemaMapper->map($entity);

        if (is_object($entity)) {
            foreach ($parsedDocument as $field => $value) {
                $entity->$field = $value;
            }
        }

        return $parsedDocument;
    }
66820
public function initializeEntity(SchemaInterface $schema)
    {
        $valueSet = $this->createValueSet();
        $valueSet->setSchema($schema);

        // To avoid persisting Value entities with no actual value to the database
        // we create empty ones, that will be removed on postPersist events.
        $this->replaceEmptyValues($valueSet);

        $entity = $schema->getObjectClass();
        $entity = new $entity();

        if (!$entity instanceof EntityInterface) {
            throw new \Exception(sprintf('The entity specified in schema "%d" schema must implement Opifer\EavBundle\Model\EntityInterface.', $schema->getId()));
        }

        $entity->setValueSet($valueSet);
        $entity->setSchema($schema);

        return $entity;
    }
994672
protected function validateBySchema(DOMDocument $document, $schema)
    {
        if (!file_exists($schema) || !is_file($schema)) {
            throw new RuntimeException(
                "Validation of XML document cannot be performed, file '{$schema}' does not exist."
            );
        }

        $additionalErrors = array();
        $pathInfo = pathinfo($schema);
        switch ($pathInfo['extension']) {
            case 'xsd':
                $document->schemaValidate($schema);
                break;
            case 'rng':
                $document->relaxNGValidate($schema);
                break;
            case 'xsl':
                $additionalErrors = $this->schematronValidate($document, $schema);
                break;
            default:
                throw new RuntimeException(
                    'Validator is capable of handling ISO Schematron (as XSLT stylesheet), ' .
                    "XSD and RELAX NG schema files, ending in .xsl, .xsd or .rng.\n" .
                    "File '{$schema}' does not seem to be either of these."
                );
        }

        return $additionalErrors;
    }
944612
public function validateMapping()
    {
        try {
            $validator = new SchemaValidator($this->entityManager);
            return $validator->validateMapping();
        } catch (\Exception $exception) {
            return [[$exception->getMessage()]];
        }
    }
269280
protected function assertEntityIsValid($entity, $scope = null)
    {
        if (!$this->validator) {
            throw new \BadMethodCallException(sprintf(
                'Method %s() cannot be used while validator is not configured.',
                __METHOD__
            ));
        }

        $scopes = $scope ? (array) $scope : null;

        $violationList = $this->validator->validate(
            $entity,
            null,
            $scopes
        );

        if (!count($violationList)) {
            return;
        }

        throw new ValidationException($entity, $violationList, $scopes);
    }
333931
protected function checkExclusiveMinimum($entity, $schema, $entityName)
    {
        if (isset($schema->minimum) && isset($schema->exclusiveMinimum) && $schema->exclusiveMinimum) {
            if ($entity == $schema->minimum) {
                throw new ValidationException(sprintf('Invalid value for [%s], must be greater than [%s]', $entityName, $schema->minimum));
            }
        }

        return $this;
    }
703840
private String validateEntity(Entity entity) throws WIMException {
        String METHODNAME = "validateEntity";
        String type = null;
        String secName = null;
        String uniqueId = null;
        String uniqueName = null;

        if (entity.getIdentifier().isSet(SchemaConstants.PROP_UNIQUE_NAME)) {
            uniqueName = entity.getIdentifier().getUniqueName();
        } else if (entity.getIdentifier().isSet(SchemaConstants.PROP_EXTERNAL_NAME)) {
            uniqueName = entity.getIdentifier().getExternalName();
        } else if (entity.getIdentifier().isSet(SchemaConstants.PROP_UNIQUE_ID)) {
            uniqueId = entity.getIdentifier().getUniqueId();
        } else if (entity.getIdentifier().isSet(SchemaConstants.PROP_EXTERNAL_ID)) {
            uniqueId = entity.getIdentifier().getExternalId();
        }

        if (uniqueName != null) {
            secName = uniqueName; // stripRDN(uniqueName);
        }

        if (uniqueId != null && uniqueId.trim().length() > 0) {
            if (isValidUserOrGroup(uniqueId)) {
                uniqueName = uniqueId;
                secName = uniqueId;
            } else {
                secName = getSecNameFromUniqueID(uniqueId);
                uniqueName = secName;
            }
        }

        if (secName != null && secName.trim().length() > 0) {
            String rdnAttr = getRDN(entity.getIdentifier().getUniqueName());
            Set<String> EntityTypes = entityConfigMap.keySet();
            List<String> entities = new ArrayList<String>();
            Iterator<String> it = EntityTypes.iterator();

            while (it.hasNext()) {
                String entityType = it.next();
                if ((rdnAttr == null) || (rdnAttr.equalsIgnoreCase(entityConfigMap.get(entityType)))) {
                    entities.add(entityType);
                }
            }
            //handle if entities.size== or >1 then respect entity.getType from input DO
            //this is better than just letting the last matching type be returned.
            String inputType = entity.getTypeName();
            type = getEntityTypeFromUniqueName(secName, entities, inputType);
            entity.getIdentifier().setUniqueName(uniqueName);
        }

        if (tc.isDebugEnabled()) {
            Tr.debug(tc, METHODNAME + " The entity type for " + secName + " is " + type);
        }
        if (type == null) {
            throw new EntityNotFoundException(WIMMessageKey.ENTITY_NOT_FOUND, Tr.formatMessage(tc, WIMMessageKey.ENTITY_NOT_FOUND,
                                                                                               WIMMessageHelper.generateMsgParms(secName)));
        }
        return type;
    }
973869
public function has(string $schema, string $typeName, string $id) : bool
    {
        if (!$this->typeExists($schema, $typeName)) {
            return false;
        }

        return array_key_exists($id, $this->storage[$schema][$typeName]);
    }
193611
public static function validate($entity)
    {
        if (Kernel::VERSION_ID >= 40000) {
            $classFound = class_exists($entity, true);

            if (!$classFound) {
                throw new \InvalidArgumentException(sprintf('Entity "%s" was not found', $entity));
            }

            return $entity;
        }

        if (!preg_match('{^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*:[a-zA-Z0-9_\x7f-\xff\\\/]+$}', $entity)) {
            throw new \InvalidArgumentException(sprintf('The entity name isn\'t valid ("%s" given, expecting something like AcmeBlogBundle:Blog/Post)', $entity));
        }

        return $entity;
    }
968935
public function validator($entity, $data)
    {
        return ValidationManager::validator(self::getInstance()->getEntityStructure($entity), $data);
    }
1223417
protected function checkTypeArray($entity, $schema, $entityName)
    {
        $this->checkMinItems($entity, $schema, $entityName);
        $this->checkMaxItems($entity, $schema, $entityName);
        $this->checkUniqueItems($entity, $schema, $entityName);
        $this->checkEnum($entity, $schema, $entityName);
        $this->checkItems($entity, $schema, $entityName);
        $this->checkDisallow($entity, $schema, $entityName);

        return $this;
    }
575656
protected function validateObjectProperty($property, Schema $schema)
    {
        list($value, $pointer) = $this->currentContext();
        $this->pushContext(array(
            $value->get($property),
            $pointer->joinAtoms($property)
        ));
        $result = $schema->accept($this);
        $this->popContext();

        return $result;
    }