function UndefinedConstraint::validateDependencies
Validate dependencies
Parameters
mixed $value:
mixed $dependencies:
JsonPointer $path:
string $i:
1 call to UndefinedConstraint::validateDependencies()
- UndefinedConstraint::validateCommonProperties in vendor/
justinrainbow/ json-schema/ src/ JsonSchema/ Constraints/ UndefinedConstraint.php - Validates common properties
File
-
vendor/
justinrainbow/ json-schema/ src/ JsonSchema/ Constraints/ UndefinedConstraint.php, line 383
Class
- UndefinedConstraint
- The UndefinedConstraint Constraints
Namespace
JsonSchema\ConstraintsCode
protected function validateDependencies($value, $dependencies, JsonPointer $path, $i = '') {
foreach ($dependencies as $key => $dependency) {
if ($this->getTypeCheck()
->propertyExists($value, $key)) {
if (is_string($dependency)) {
// Draft 3 string is allowed - e.g. "dependencies": {"bar": "foo"}
if (!$this->getTypeCheck()
->propertyExists($value, $dependency)) {
$this->addError($path, "{$key} depends on {$dependency} and {$dependency} is missing", 'dependencies');
}
}
elseif (is_array($dependency)) {
// Draft 4 must be an array - e.g. "dependencies": {"bar": ["foo"]}
foreach ($dependency as $d) {
if (!$this->getTypeCheck()
->propertyExists($value, $d)) {
$this->addError($path, "{$key} depends on {$d} and {$d} is missing", 'dependencies');
}
}
}
elseif (is_object($dependency)) {
// Schema - e.g. "dependencies": {"bar": {"properties": {"foo": {...}}}}
$this->checkUndefined($value, $dependency, $path, $i);
}
}
}
}