Example #1
0
 public function testValidate()
 {
     $mockSchema = $this->getMockBuilder(SchemaInterface::class)->getMock();
     $property = new Property($mockSchema, 'testProperty', ['required' => true]);
     $result = $property->validate('foobar');
     $this->assertInstanceOf(Ok::class, $result);
 }
Example #2
0
 /**
  * @param SchemaInterface $schema The schema that the property is part of.
  * @param string $name The name of the schema.
  * @param mixed[] $definition Must contain a key named 'one_of' containing the values,
  *                            that will be allowed to pass the property's validation.
  * @param PropertyInterface $parent If the schema is created by an assoc or sequence prop,
  *                                  this must be the creating parent property.
  */
 public function __construct(SchemaInterface $schema, $name, array $definition, PropertyInterface $parent = null)
 {
     parent::__construct($schema, $name, $definition, $parent);
     $this->choices = isset($definition['one_of']) ? $definition['one_of'] : [];
 }
Example #3
0
 /**
  * @param SchemaInterface $schema The schema that the property is part of.
  * @param string $name The name of the schema.
  * @param mixed[] $definition Must contain a key named 'properties' that defines a schema,
  *                            which the property will proxy validation to.
  * @param PropertyInterface $parent If the schema is created by an assoc or sequence prop,
  *                                  this must be the creating parent property.
  */
 public function __construct(SchemaInterface $schema, $name, array $definition, PropertyInterface $parent = null)
 {
     parent::__construct($schema, $name, $definition, $parent);
     $this->valueSchema = $this->createValueSchema($definition);
 }