public function __construct($value)
 {
     if (!is_bool($value) && !$value instanceof Schema) {
         throw new \InvalidArgumentException("AdditionalProperties constraints require the value to be a boolean or a Schema");
     }
     parent::__construct($value);
 }
Beispiel #2
0
 public function __construct($value)
 {
     if (!$value instanceof Schema) {
         throw new \InvalidArgumentException("Not constraints require the value to be a Schema");
     }
     parent::__construct($value);
 }
Beispiel #3
0
 public function __construct($value)
 {
     if (is_array($value)) {
         foreach ($value as $item) {
             if (!$item instanceof Schema) {
                 throw new \InvalidArgumentException("The elements of an Item constraint array must be one of the Schema classes");
             }
         }
     } elseif (!$value instanceof Schema) {
         throw new \InvalidArgumentException("Items constraints require the check value to be a Schema or an array of Schemas");
     }
     parent::__construct($value);
 }
Beispiel #4
0
 public function __construct($value)
 {
     if (!is_array($value)) {
         throw new \InvalidArgumentException("The " . __CLASS__ . " constraint requires an array of values");
     }
     foreach ($value as $i => $schema) {
         if (!$schema instanceof Schema) {
             throw new \InvalidArgumentException("The element for key: {$i} was not a schema object");
         }
     }
     if (empty($value)) {
         throw new \InvalidArgumentException("The value array did not contain any schema objects");
     }
     parent::__construct($value);
 }
Beispiel #5
0
 public function __construct($value)
 {
     if (is_object($value)) {
         $value = (array) $value;
     }
     foreach ($value as $key => $dependency) {
         if (is_numeric($key)) {
             throw new \InvalidArgumentException("Dependencies constraints require the keys for the value elements to be non-numeric");
         }
         if (!(is_array($dependency) && count($dependency) > 0) || !$dependency instanceof Schema) {
             throw new \InvalidArgumentException("Dependencies constraints require the value elements to be non-empty arrays or Schemas");
         }
     }
     parent::__construct($value);
 }
Beispiel #6
0
 public function __construct($value)
 {
     if (is_object($value)) {
         $value = (array) $value;
     }
     // validate an associative array
     if (!is_array($value)) {
         throw new \InvalidArgumentException(__CLASS__ . " constraints require their value to be an object or an associative array");
     }
     foreach ($value as $prop => $schemata) {
         if (is_numeric($prop)) {
             throw new \InvalidArgumentException(__CLASS__ . " constraints require their value to be an object or an associative array");
         }
         if (!$schemata instanceof Schema) {
             throw new \InvalidArgumentException(__CLASS__ . " constraints require each value element to be a Schema");
         }
     }
     parent::__construct($value);
 }