Respect\Validation\Exceptions\ValidationException::getMainMessage PHP Method

getMainMessage() public method

public getMainMessage ( )
    public function getMainMessage()
    {
        $vars = $this->getParams();
        $vars['name'] = $this->getName();
        $template = $this->getTemplate();
        if (isset($vars['translator']) && is_callable($vars['translator'])) {
            $template = call_user_func($vars['translator'], $template);
        }
        return static::format($template, $vars);
    }

Usage Example

 public function testGetMainMessageShouldApplyTemplatePlaceholders()
 {
     $sampleValidationException = new ValidationException();
     $sampleValidationException->configure('foo', ['bar' => 1, 'baz' => 2]);
     $sampleValidationException->setTemplate('{{name}} {{bar}} {{baz}}');
     $this->assertEquals('foo 1 2', $sampleValidationException->getMainMessage());
 }