示例#1
0
 public function validate($json, $schema)
 {
     $this->report = new Report(null, $this->options);
     if (is_object($schema)) {
         $schema = $this->cache->getSchemaByReference($schema);
     }
     if (is_string($schema)) {
         $schema = $this->cache->getSchemaByUri($this->report, $schema);
     }
     $compiled = $this->compiler->compileSchema($this->report, $schema);
     if (!$compiled) {
         return false;
     }
     $validated = $this->schemaValidator->validateSchema($this->report, $schema);
     if (!$validated) {
         return false;
     }
     $this->jsonValidator->validate($this->report, $schema, $json);
     return $this->report->isValid();
 }