Check for valid entity.
972118
public function isValidEntity($entity) {
    if ($entity->getEntityTypeId() === 'mentions') {
      return TRUE;
    }

    // Special cases for comments and posts.
    $allowed_content_types = [
      'comment',
    ];
    if (in_array($entity->getEntityTypeId(), $allowed_content_types)) {
      $mentions = $this->getMentionsFromRelatedEntity($entity);
      if (!empty($mentions)) {
        return TRUE;
      }
    }
    return FALSE;
  }
623281
def _validate_entity(entity):
    '''
    
    '''

    #Validate entity:
    if entity['type'] == 'cluster':
        schema = ESXClusterEntitySchema.serialize()
    elif entity['type'] == 'vcenter':
        schema = VCenterEntitySchema.serialize()
    else:
        raise ArgumentValueError('Unsupported entity type \'{0}\''
                                 ''.format(entity['type']))
    try:
        jsonschema.validate(entity, schema)
    except jsonschema.exceptions.ValidationError as exc:
        raise InvalidEntityError(exc)
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;
    }
1147112
def is_valid(cls, arg):
        """"""
        if not isinstance(arg, (int, long)) or isinstance(arg, bool):
            return False
        if (arg < cls._low_limit):
            return False
        if (cls._high_limit is not None) and (arg > cls._high_limit):
            return False
        return True
206244
def _validated(self, data):
        """"""
        errors = []
        for sub in self.schemas:
            try:
                return sub(data)
            except NotValid as ex:
                errors.extend(ex.args)

        raise NotValid(' and '.join(errors))
1038037
def _validate_entity_cls(self, entity_cls):
        """"""
        # Import here to avoid cyclic dependency
        from protean.core.entity import Entity

        if not issubclass(entity_cls, Entity):
            raise AssertionError(
                f'Entity {entity_cls.__name__} must be subclass of `Entity`')

        if entity_cls.meta_.abstract is True:
            raise NotSupportedError(
                f'{entity_cls.__name__} class has been marked abstract'
                f' and cannot be instantiated')
153118
protected void checkEntity(InputProblemReporter rep, String id, EntityDecl ent)
        throws XMLStreamException
    {
        if (ent == null) {
            rep.reportValidationProblem("Referenced entity '"+id+"' not defined");
        } else if (ent.isParsed()) {
            rep.reportValidationProblem("Referenced entity '"+id+"' is not an unparsed entity");
        }
    }
1015991
protected function validate()
    {
        if (!$this->validator instanceof ValidatorInterface) {
            return;
        }

        $valid = true;
        if ($this->getEntityContainerMap()->count() > 0) {
            $entityContainers = $this->getEntityContainerMap()->getAll();

            $this->logger->debug('start form entity valiation', array('name' => $this->getName()));

            /**
             * @var $entityContainer    \Naucon\Form\Mapper\EntityContainerInterface
             */
            foreach ($entityContainers as $entityContainer) {
                if ($entityContainer->hasValidate()) {
                    $this->logger->debug('invoke form prevalidator hook', array('name' => $this->getName(), 'entity' => $entityContainer->getName()));
                    // prevalidation hook
                    $entityContainer->invokeHook('prevalidatorHook');

                    $violations = $this->validator->validate($entityContainer->getEntity(), null, $this->configuration->get('validation_groups'));
                    if (is_array($violations) && count($violations)) {
                        // TODO set FormValidations to $entityContainer
                        /**
                         * @var \Naucon\Form\Validator\ViolationInterface $violation
                         */
                        $violationsDump = array();
                        foreach ($violations as $violation) {
                            $violationsDump[$violation->getName()] = $violation->getMessage();
                            $entityContainer->setError($violation->getName(), new FormError($violation->getName(), $violation->getMessage()));
                        }
                        $valid = false;

                        $this->logger->debug('form entity violations', array('name' => $this->getName(), 'entity' => $entityContainer->getName(), 'violations' => $violationsDump));
                    }

                    // postvalidation hook
                    $this->logger->debug('invoke form postvalidator hook', array('name' => $this->getName(), 'entity' => $entityContainer->getName()));
                    $entityContainer->invokeHook('postvalidatorHook');

                    if ($entityContainer->hasErrors()) {
                        $valid = false;
                    }
                }
            }
        }

        if ($valid) {
            $this->logger->debug('finished form entity valiation successful', array('name' => $this->getName()));
        } else {
            $this->logger->debug('finished form entity valiation failed', array('name' => $this->getName()));
        }
        $this->setValid($valid);
    }
1234202
def assert_valid(self, instance, value=None):
        """"""
        valid = super(Union, self).assert_valid(instance, value)
        if not valid:
            return False
        if value is None:
            value = instance._get(self.name)
            if value is None:
                return True
        return self._try_prop_method(instance, value, 'assert_valid')
677286
def is_valid(cls, arg):
        """"""
        return isinstance(arg, (int, long)) and (not isinstance(arg, bool))
816923
def validate(self, obj):
        """"""
        try:
            if self.resolver is not None:
                jsonschema.validate(obj, self.schema, resolver=self.resolver)
            else:
                jsonschema.validate(obj, self.schema)
        except jsonschema.ValidationError as exc:
            raise exceptions.ValidationError(str(exc))
989594
def validate(self):
        """"""
        # check if required_fields aren't present
        for field in set(self.required_fields) - set(self.request_data):
            if not isinstance(field, string_types):
                # field was a collection, iterate over it and check by OR
                return bool(set(field) & set(self.request_data))
            return False
        return True
726640
def validate(self, model, checks=[]):
        """"""
        records = self.data.to_dict("records")
        self.evaluate_report(
            validate(records, headers=list(records[0]),
                     preset='table', schema=self.schema,
                     order_fields=True, custom_checks=checks))
446942
private function checkEntityExist()
    {
        if (!file_exists(PATH_HOME . "entity/cache/{$this->entity}.json")) {
            foreach (Helper::listFolder(PATH_HOME . VENDOR) as $lib)
                new \LinkControl\EntityImport($lib);
        }
    }
1201481
public function valid()
    {
        $encryptStr = "";
        if ($_SERVER['REQUEST_METHOD'] == "POST") {
            $postStr = file_get_contents("php://input");
            $disableEntities = libxml_disable_entity_loader(true);
            $array = (array)simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
            libxml_disable_entity_loader($disableEntities);
            $this->encrypt_type = isset($_GET["encrypt_type"]) ? $_GET["encrypt_type"] : '';
            if ($this->encrypt_type == 'aes') {
                $encryptStr = $array['Encrypt'];
                !class_exists('Prpcrypt', false) && require __DIR__ . '/Prpcrypt.php';
                $pc = new Prpcrypt($this->encodingAesKey);
                $array = $pc->decrypt($encryptStr, $this->appid);
                if (!isset($array[0]) || intval($array[0]) > 0) {
                    $this->errCode = $array[0];
                    $this->errMsg = $array[1];
                    Tools::log("Interface Authentication Failed. {$this->errMsg}[{$this->errCode}]", "ERR - {$this->appid}");
                    return false;
                }
                $this->postxml = $array[1];
                empty($this->appid) && $this->appid = $array[2];
            } else {
                $this->postxml = $postStr;
            }
        } elseif (isset($_GET["echostr"])) {
            if ($this->checkSignature()) {
                @ob_clean();
                exit($_GET["echostr"]);
            }
            return false;
        }
        if (!$this->checkSignature($encryptStr)) {
            $this->errMsg = 'Interface authentication failed, please use the correct method to call.';
            return false;
        }
        return true;
    }
668428
def valid(*things):
	''''''
	for thing in things:
		if type(thing) is str and not os.path.exists(thing):
			return False
		if thing.valid is None:
			return False
	return True
1146514
def validate_entities(self, model, context=None):
        
        result = Result()
        for property_name in self.entities:
            prop = self.entities[property_name]
            value = self.get(model, property_name)

            errors = prop.validate(
                value=value,
                model=model,
                context=context
            )
            if len(errors):
                result.add_entity_errors(
                    property_name=property_name,
                    direct_errors=errors
                )

            if value is None:
                continue

            schema_valid = prop.validate_with_schema(
                model=value,
                context=context
            )
            if schema_valid == False:
                result.add_entity_errors(
                    property_name,
                    schema_errors=schema_valid.errors
                )

        return result