protected function validateObject($object)
{
$classSchema = $this->reflectionService->getClassSchema($object);
$validator = $this->validatorResolver->getBaseValidatorConjunction($classSchema->getClassName());
if ($validator === null) {
return;
}
$validationResult = $validator->validate($object);
if ($validationResult->hasErrors()) {
$errorMessages = '';
$allErrors = $validationResult->getFlattenedErrors();
foreach ($allErrors as $path => $errors) {
$errorMessages .= $path . ':' . PHP_EOL;
foreach ($errors as $error) {
$errorMessages .= (string) $error . PHP_EOL;
}
}
throw new ObjectValidationFailedException('An instance of "' . get_class($object) . '" failed to pass validation with ' . count($errors) . ' error(s): ' . PHP_EOL . $errorMessages, 1322585162);
}
}