22 private $objectManager;
27 private $validatorResultFactory;
37 ValidatorResultInterfaceFactory $validatorResult
40 $this->validatorResultFactory = $validatorResult;
53 $validatorArguments = [];
54 if ($context !==
null) {
55 $validatorArguments[
'context'] = $context;
58 foreach ($validators as $validatorName) {
59 $validator = $this->objectManager->create($validatorName, $validatorArguments);
62 __(
'The "%1" validator is not an instance of the general validator interface.', $validatorName)
65 $messages = array_merge($messages, $validator->validate(
$entity));
67 $validationResult = $this->validatorResultFactory->create();
69 $validationResult->addMessage(
$message);
72 return $validationResult;
__construct(ObjectManagerInterface $objectManager, ValidatorResultInterfaceFactory $validatorResult)
validate($entity, array $validators, $context=null)