示例#1
0
 /**
  * Validates the given data against the schema and returns an object containing the results
  * Both the php object and the schema are supposed to be a result of a json_decode call.
  * The validation works as defined by the schema proposal in http://json-schema.org
  *
  * {@inheritDoc}
  */
 public function check($value, $schema = null, $path = null, $i = null)
 {
     $validator = new SchemaConstraint($this->checkMode, $this->uriRetriever);
     $validator->check($value, $schema);
     $this->addErrors(array_unique($validator->getErrors(), SORT_REGULAR));
 }
示例#2
0
 /**
  * Checks a schema element
  *
  * @param mixed $value
  * @param mixed $schema
  * @param mixed $path
  * @param mixed $i
  */
 protected function checkSchema($value, $schema, $path = null, $i = null)
 {
     if (is_object($schema)) {
         $retriever = $this->getUriRetriever();
         $schemaId = $retriever->cacheSchema($schema);
     } elseif (is_string($schema)) {
         $schema = $this->retrieveSchema($schema);
         $schemaId = $schema->id;
     }
     $validator = new SchemaConstraint($this->checkMode, $this->uriRetriever, $this->uriResolver, $schemaId);
     $validator->check($value, $schema, $path, $i);
     $this->addErrors($validator->getErrors());
 }