protected function JsonBlueprintDenormalizer::validateInput in Subrequests 8.2
Same name and namespace in other branches
- 3.x src/Normalizer/JsonBlueprintDenormalizer.php \Drupal\subrequests\Normalizer\JsonBlueprintDenormalizer::validateInput()
Validates the consumers's blueprint against the subrequests payload format.
Parameters
mixed $input: The blueprint sent by the consumer.
Return value
bool FALSE if the input failed validation, otherwise TRUE.
1 call to JsonBlueprintDenormalizer::validateInput()
- JsonBlueprintDenormalizer::doValidateInput in src/
Normalizer/ JsonBlueprintDenormalizer.php - Wraps validation in an assert to prevent execution in production.
File
- src/
Normalizer/ JsonBlueprintDenormalizer.php, line 179
Class
- JsonBlueprintDenormalizer
- Denormalizer that builds the blueprint based on the incoming blueprint.
Namespace
Drupal\subrequests\NormalizerCode
protected function validateInput($input) {
// If the validator isn't set, then the validation library is not installed.
if (!$this->validator) {
return TRUE;
}
$schema_path = dirname(dirname(__DIR__)) . '/schema.json';
$this->validator
->validate($input, (object) [
'$ref' => 'file://' . $schema_path,
]);
if (!$this->validator
->isValid()) {
// Log any potential errors.
$this->logger
->debug('Consumer\'s blueprint failed validation: @data', [
'@data' => Json::encode($input),
]);
$this->logger
->debug('Validation errors: @errors', [
'@errors' => Json::encode($this->validator
->getErrors()),
]);
}
return $this->validator
->isValid();
}