Added the possibility to add the value in the exception message
This commit is contained in:
parent
6b4538a1c4
commit
27e2ec139d
@ -157,13 +157,15 @@ class ExprBuilder
|
|||||||
/**
|
/**
|
||||||
* Sets a closure marking the value as invalid at validation time.
|
* Sets a closure marking the value as invalid at validation time.
|
||||||
*
|
*
|
||||||
|
* if you want to add the value of the node in your message just use a %s placeholder.
|
||||||
|
*
|
||||||
* @param string $message
|
* @param string $message
|
||||||
*
|
*
|
||||||
* @return Symfony\Component\DependencyInjection\Configuration\Builder\ExprBuilder
|
* @return Symfony\Component\DependencyInjection\Configuration\Builder\ExprBuilder
|
||||||
*/
|
*/
|
||||||
public function thenInvalid($message)
|
public function thenInvalid($message)
|
||||||
{
|
{
|
||||||
$this->thenPart = function ($v) use ($message) {throw new \InvalidArgumentException($message); };
|
$this->thenPart = function ($v) use ($message) {throw new \InvalidArgumentException(sprintf($message, $v)); };
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user