ModelBundle/Validator/Constraints/CheckRoutePatternValidator.php
public function validate($value, Constraint $constraint)
    {
        $nodesSameRoute = $this->nodeRepository->findByParentAndRoutePattern(
            $value->getParentId(),
            $value->getRoutePattern(),
            $value->getNodeId(),
            $value->getSiteId()
        );
        if (0 < count($nodesSameRoute)) {
            $nodesSameRoute = current($nodesSameRoute);
            $message = $constraint->message;
            if (true === $nodesSameRoute->isDeleted()) {
                $message = $constraint->messageWitNodeDeleted;
            }
            $this->context->buildViolation($message, array("%nodeName%" => $nodesSameRoute->getName()))
                ->atPath('routePattern')
                ->addViolation();
        }
    }
public function validate($value, Constraint $constraint)
    {
        $nodesSameRoute = $this->nodeRepository->findByParentAndRoutePattern(
            $value->getParentId(),
            $value->getRoutePattern(),
            $value->getNodeId(),
            $value->getSiteId()
        );
        if (0 < count($nodesSameRoute)) {
            $nodesSameRoute = current($nodesSameRoute);
            $message = $constraint->message;
            if (true === $nodesSameRoute->isDeleted()) {
                $message = $constraint->messageWitNodeDeleted;
            }
            $this->context->buildViolation($message, array("%nodeName%" => $nodesSameRoute->getName()))
                ->atPath('routePattern')
                ->addViolation();
        }
    }
Checks if the passed value is valid.

@param NodeInterface $value The value that should be validated
@param Constraint    $constraint The constraint for the validation