Short description of method validate

@access public
@author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
@param  string schema
@return boolean
1473
public function validate($schema = '')
    {
        //You know sometimes you think you have enough time, but it is not always true ...
        //(timeout in hudson with the generis-hard test suite)
        helpers_TimeOutHelper::setTimeOutLimit(helpers_TimeOutHelper::MEDIUM);
        
        $content = $this->getContent();
        if (!empty($content)) {
            try {
                libxml_use_internal_errors(true);

                $dom = new DomDocument();
                $dom->formatOutput = true;
                $dom->preserveWhiteSpace = false;
                
                $this->valid = $dom->loadXML($content);

                if ($this->valid && !empty($schema)) {
                    $this->valid = $dom->schemaValidate($schema);
                }

                if (!$this->valid) {
                    $this->addErrors(libxml_get_errors());
                }
                libxml_clear_errors();
            } catch(DOMException $de) {
                $this->addError($de);
            }
        }
        
        
        helpers_TimeOutHelper::reset();
        return (bool) $this->valid;
    }
856978
public void validate(Schema schema) {
        if (queryCondition != null || filterCondition != null) {
            query(schema, null);
        }
        if (sort != null) {
            sort.sort(schema);
        }
    }
625645
protected function validateProperties($entity, $schema, $entityName)
    {
        $properties = get_object_vars($entity);

        if (!isset($schema->properties)) {
        	return $this;
            //throw new SchemaException(sprintf('No properties defined for [%s]', $entityName));
        }

        // Check defined properties
        foreach($schema->properties as $propertyName => $property) {
            if (array_key_exists($propertyName, $properties)) {
                // Check type
                $path = $entityName . '.' . $propertyName;
                $this->validateType($entity->{$propertyName}, $property, $path);
            } else {
                // Check required
                if (isset($property->required) && $property->required) {
                    throw new ValidationException(sprintf('Missing required property [%s] for [%s]', $propertyName, $entityName));
                }
            }
        }

        // Check additional properties
        if (isset($schema->additionalProperties) && !$schema->additionalProperties) {
            $extra = array_diff(array_keys((array)$entity), array_keys((array)$schema->properties));
            if (count($extra)) {
                throw new ValidationException(sprintf('Additional properties [%s] not allowed for property [%s]', implode(',', $extra), $entityName));
            }
        }

        return $this;
    }
809508
public static boolean validate(final Source input, final Source[] schemas) {
        boolean isValid = true;
        try {
            final SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            factory.setResourceResolver(new SchemaLSResourceResolver());
            final Validator val = factory.newSchema(schemas).newValidator();
            final ParserErrorHandler eh = new ParserErrorHandler();
            val.setErrorHandler(eh);
            val.validate(input);
            if (eh.didErrorOccur()) {
                isValid = false;
                eh.logErrors(LOGGER);
            }
        } catch (final Exception ex) {
            LOGGER.error("Problem validating the given process definition.", ex);
            isValid = false;
        }

        return isValid;
    }
1084832
public function validate($schema = ''){
        
        if (empty($schema)) {
            
            // Let's detect NS in use...
            $dom = new DOMDocument('1.0', 'UTF-8');

            switch($this->sourceType){
                case self::SOURCE_FLYFILE:
                    if ($this->source->exists()) {
                        $dom->load($this->source->read());
                    }
                    break;
                case self::SOURCE_FILE:
                    $dom->load($this->source);
                    break;
                case self::SOURCE_URL:
                    $xmlContent = tao_helpers_Request::load($this->source, true);
                    $dom->loadXML($xmlContent);
                    break;
                case self::SOURCE_STRING:
                    $dom->loadXML($this->source);
                    break;
            }

            // Retrieve Root's namespace.
            if( $dom->documentElement == null ){
                $this->addError('dom is null and could not be validate');
                $returnValue = false;
            } else {
                $ns = $dom->documentElement->lookupNamespaceUri(null);
                $servicemanager = $this->getServiceManager();
                $validationService = $servicemanager->get(ValidationService::SERVICE_ID);
                $schemas = $validationService->getContentValidationSchema($ns);
                $this->logDebug("The following schema will be used to validate: '" . $schemas[0] . "'.");

                $validSchema = $this->validateMultiple($schemas);
                $returnValue = $validSchema !== '';
            }
        } elseif(!file_exists($schema)) {
            throw new \common_Exception('no schema found in the location '.$schema);
        } else {
            $returnValue = parent::validate($schema);
        }

        return (bool) $returnValue;
    }
788400
protected function validateSchema(&$document_data, &$data, array $data_pointer, array $parent_data_pointer, ISchema $document, $schema, ValidationResult $bag): bool
    {
        if (is_bool($schema)) {
            if ($schema) {
                return true;
            }
            $bag->addError(new ValidationError($data, $data_pointer, $parent_data_pointer, $schema, '$schema', [
                'schema' => $schema
            ]));
            return false;
        }

        if (!is_object($schema)) {
            throw new InvalidSchemaException($schema);
        }

        if (property_exists($schema, '$ref') && is_string($schema->{'$ref'})) {
            return $this->validateRef($document_data, $data, $data_pointer, $parent_data_pointer, $document, $schema, $bag);
        }

        return $this->validateKeywords($document_data, $data, $data_pointer, $parent_data_pointer, $document, $schema, $bag);
    }
403183
protected function validate()
    {
        // Do not perform request validation/transformation if it is disable
        if ($this[self::DISABLE_VALIDATION]) {
            return;
        }

        $errors = array();
        $validator = $this->getValidator();
        foreach ($this->operation->getParams() as $name => $schema) {
            $value = $this[$name];
            if (!$validator->validate($schema, $value)) {
                $errors = array_merge($errors, $validator->getErrors());
            } elseif ($value !== $this[$name]) {
                // Update the config value if it changed and no validation errors were encountered
                $this->data[$name] = $value;
            }
        }

        // Validate additional parameters
        $hidden = $this[self::HIDDEN_PARAMS];

        if ($properties = $this->operation->getAdditionalParameters()) {
            foreach ($this->toArray() as $name => $value) {
                // It's only additional if it isn't defined in the schema
                if (!$this->operation->hasParam($name) && !in_array($name, $hidden)) {
                    // Always set the name so that error messages are useful
                    $properties->setName($name);
                    if (!$validator->validate($properties, $value)) {
                        $errors = array_merge($errors, $validator->getErrors());
                    } elseif ($value !== $this[$name]) {
                        $this->data[$name] = $value;
                    }
                }
            }
        }

        if (!empty($errors)) {
            $e = new ValidationException('Validation errors: ' . implode("\n", $errors));
            $e->setErrors($errors);
            throw $e;
        }
    }
1227692
public function schemaValidate()
    {
        if (!$this->xml_data) {
            \sasco\LibreDTE\Log::write(
                \sasco\LibreDTE\Estado::DOCUMENTO_FALTA_XML,
                \sasco\LibreDTE\Estado::get(
                    \sasco\LibreDTE\Estado::DOCUMENTO_FALTA_XML,
                    substr(get_class($this), strrpos(get_class($this), '\\')+1)
                )
            );
            return null;
        }
        $this->xml = new \sasco\LibreDTE\XML();
        $this->xml->loadXML($this->xml_data);
        $schema = $this->xml->getSchema();
        if (!$schema) {
            $tag = array_keys($this->toArray())[0];
            if (isset($this->schemas[$tag])) {
                $schema = $this->schemas[$tag];
            }
        }
        if ($schema) {
            $xsd = dirname(dirname(dirname(dirname(__FILE__)))).'/schemas/'.$schema;
        }
        if (!$schema or !is_readable($xsd)) {
            \sasco\LibreDTE\Log::write(
                \sasco\LibreDTE\Estado::DOCUMENTO_FALTA_SCHEMA,
                \sasco\LibreDTE\Estado::get(
                    \sasco\LibreDTE\Estado::DOCUMENTO_FALTA_SCHEMA
                )
            );
            return null;
        }
        $result = $this->xml->schemaValidate($xsd);
        if (!$result) {
            \sasco\LibreDTE\Log::write(
                \sasco\LibreDTE\Estado::DOCUMENTO_ERROR_SCHEMA,
                \sasco\LibreDTE\Estado::get(
                    \sasco\LibreDTE\Estado::DOCUMENTO_ERROR_SCHEMA,
                    substr(get_class($this), strrpos(get_class($this), '\\')+1),
                    implode("\n", $this->xml->getErrors())
                )
            );
        }
        return $result;
    }
995071
public function validate($schema, $json)
    {
        $validator = new Validator;

        $validator->check($json, $schema);

        if (false === $validator->isValid()) {
            $errors = array();

            foreach ($validator->getErrors() as $error) {
                $errors[] = (empty($error['property']) ? '' : $error['property'] . ': ')
                          . $error['message'];
            }

            throw JSONException::errors($errors);
        }
    }
103276
def validate(ctx, schema, all_schemata):
    """"""

    database = ctx.obj['db']

    if schema is None:
        if all_schemata is False:
            log('No schema given. Read the help', lvl=warn)
            return
        else:
            schemata = database.objectmodels.keys()
    else:
        schemata = [schema]

    for schema in schemata:
        try:
            things = database.objectmodels[schema]
            with click.progressbar(things.find(), length=things.count(),
                                   label='Validating %15s' % schema) as object_bar:
                for obj in object_bar:
                    obj.validate()
        except Exception as e:

            log('Exception while validating:',
                schema, e, type(e),
                '\n\nFix this object and rerun validation!',
                emitter='MANAGE', lvl=error)

    log('Done')
132461
public static function buildValidation(array $schema, $name = null)
    {
        $validation = new NestedValidation($name);

        foreach ($schema as $key => $value) {

            if (!is_array($value)) {
                trigger_error('parsing error', E_USER_ERROR);
            }

            if (self::isNestedValidation($value)) {
                $validation->addValidation(self::buildValidation($value, $key));
            } else {
                $validation->addValidation(self::buildKeyValidation($value, $key));
            }

        }
        return $validation;
    }
431468
public function makeSubSchemaValidator($data, $schema, $dataPath = null, $schemaPath = null)
    {
        $validator = new Validator($data, $schema, $this->ruleSet);

        $validator->dataPath         = $dataPath ?: $this->dataPath;
        $validator->baseSchemaPath   = $schemaPath ?: $this->getSchemaPath();
        $validator->maxDepth         = $this->maxDepth;
        $validator->depth            = $this->depth + 1;

        return $validator;
    }
912386
public function setSchema($schema)
    {
        $schema = array($schema);
        if (func_num_args() > 0) {
            $schema = func_get_args();
        }
        
        $error = Argument::i();
        foreach ($schema as $i => $name) {
            $error->test($i + 1, 'string');
        }
        
        $schema = implode(',', $schema);
        
        $query = $this->utility()->setSchema($schema);
        $this->query($query);
        
        return $this;
    }
1206309
public function validateSchema()
    {
        $meta_schema_validator = new SchemaValidator();
        $json_loader = new JsonLoader();

        // we have to check if we use a prefix
        $meta_json = file_get_contents(__DIR__.'/../../../data/MetaSchema.json');
        $meta_json = str_replace('#', $this->prefix, $meta_json);

        // we validate the schema using the meta schema, defining the structure of our schema
        $meta_schema_validator->validate($json_loader->load($meta_json), $this->schema);

        return true;
    }
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;
    }
1216341
public function validate() : bool
    {
        $table = $this->getConfig()->getTable();
        foreach ([$this->config->getField(), $this->config->getDisplayField()] as $field) {
            if ($table->getSchema()->hasColumn($field)) {
                continue;
            }

            $this->errors[] = sprintf('Unknown column "%s" for table "%s"', $field, $table->getAlias());
        }

        return empty($this->errors);
    }
1028345
public XmlAssert isNotValidAgainst(Schema schema) {
        isNotNull();
        ValidationAssert.create(actual, schema).isInvalid();
        return this;
    }