public function prependValidator(ValidatorInterface $validator,
                                     $showMessages = true,
                                     $leadingTemplate = null,
                                     $trailingTemplate = null)
    {
        $priority = self::DEFAULT_PRIORITY;
        if (!$this->validators->isEmpty()) {
            $queue = $this->validators->getIterator();
            $queue->setExtractFlags(PriorityQueue::EXTR_PRIORITY);
            $extractedNode = $queue->extract();
            $priority = $extractedNode[0] + 1;
        }
    
        $this->validators->insert(
            array(
                'instance' => $validator,
                'show_messages' => (bool) $showMessages,
                'leading_message_template' => $leadingTemplate,
                'trailing_message_template' => $trailingTemplate,
            ),
            $priority
        );
        return $this;
    }