/** * Validates an instance against a given schema and returns a list * of violations, if any. If the schema contains relative remote * references, its (absolute) URI must be passed as argument. * * @param mixed $instance * @param stdClass $schema * @param string $schemaUri * * @return array */ public function validate($instance, stdClass $schema, $schemaUri = '') { $parseContext = new Context(); $constraintContext = new Context(); // todo: keep ref of already resolved/parsed schemas $schema = $this->walker->resolveReferences($schema, new Uri($schemaUri)); $schema = $this->walker->parseSchema($schema, $parseContext); $this->walker->applyConstraints($instance, $schema, $constraintContext); return $constraintContext->getViolations(); }