/** * {@inheritdoc} */ public function apply($instance, stdClass $schema, Context $context, Walker $walker) { $altContext = $context->duplicate(); $walker->applyConstraints($instance, $schema->not, $altContext); if ($altContext->countViolations() === $context->countViolations()) { $context->addViolation('should not match schema in "not"'); } }
/** * {@inheritdoc} */ public function apply($instance, stdClass $schema, Context $context, Walker $walker) { $originalCount = $context->countViolations(); foreach ($schema->allOf as $subSchema) { $walker->applyConstraints($instance, $subSchema, $context); } if ($context->countViolations() > $originalCount) { $context->addViolation('instance must match all the schemas listed in allOf'); } }