Example #1
0
 /**
  * Constructor.
  *
  * @param string $context
  */
 public function __construct($context)
 {
     $factory = new Factory();
     $factory->setConstraintClass('request body', SchemaConstraint::class);
     $factory->setConstraintClass('response body', SchemaConstraint::class);
     $this->validator = $factory->createInstanceFor($context);
     $this->context = $context;
 }
Example #2
0
 /**
  * Checks format of an element
  *
  * @param mixed            $value
  * @param mixed            $schema
  * @param JsonPointer|null $path
  * @param mixed            $i
  */
 protected function checkFormat($value, $schema = null, JsonPointer $path = null, $i = null)
 {
     $validator = $this->factory->createInstanceFor('format');
     $validator->check($value, $schema, $path, $i);
     $this->addErrors($validator->getErrors());
 }