in src/Api/Validator.php [91:130]
private function check_structure(StructureShape $shape, $value)
{
$isDocument = (isset($shape['document']) && $shape['document']);
$isUnion = (isset($shape['union']) && $shape['union']);
if ($isDocument) {
if (!$this->checkDocumentType($value)) {
$this->addError("is not a valid document type");
return;
}
} elseif ($isUnion) {
if (!$this->checkUnion($value)) {
$this->addError("is a union type and must have exactly one non null value");
return;
}
} elseif (!$this->checkAssociativeArray($value)) {
return;
}
if ($this->constraints['required'] && $shape['required']) {
foreach ($shape['required'] as $req) {
if (!isset($value[$req])) {
$this->path[] = $req;
$this->addError('is missing and is a required parameter');
array_pop($this->path);
}
}
}
if (!$isDocument) {
foreach ($value as $name => $v) {
if ($shape->hasMember($name)) {
$this->path[] = $name;
$this->dispatch(
$shape->getMember($name),
isset($value[$name]) ? $value[$name] : null
);
array_pop($this->path);
}
}
}
}