validateObject($value, $constraint); } elseif ($value instanceof StoredObject) { $this->validateObject($value->getCurrentVersion(), $constraint); } else { throw new \Symfony\Component\Form\Exception\UnexpectedTypeException($value, StoredObjectVersion::class); } } protected function validateObject(StoredObjectVersion $file, AsyncFileExists $constraint): void { if (!$this->storedObjectManager->exists($file)) { $this->context->buildViolation($constraint->message) ->setParameter('{{ filename }}', $file->getFilename()) ->addViolation(); } } }