How can I customize response messages for the user #312

andretx
Member | 2
+
0
-

how can I customize response messages for the user

try {
	$arr = ['title' => 'aa', 'bar' => 'a', 'foo' => 'a'];
	v::assert($arr['title'], 'string:5', 'example message 1');
	v::assert($arr['bar'], 'string:15', 'example message 2');
	v::assert($arr['foo'], 'int', 'example message 3');
} catch (AssertionException $e) {
	echo '<pre>'; print_r($e->getMessage());
}

current answer
The example message 1 expects to be string in range 5, string ‘aa’ given.

the current message appears between the default message.

thanks

Marek Bartoš
Nette Blogger | 1246
+
0
-

Does this class of yours called v perhaps have some different name that we may know?

andretx
Member | 2
+
0
-

Sorry, this class name

use Nette\Utils\Validators as v;
use Nette\Utils\AssertionException;