Added {{input}} param on AbstractRule

This commit is contained in:
Alexandre Gomes Gaigalas 2011-04-29 16:17:20 -03:00
parent e635db4a19
commit 67c789fa92
4 changed files with 9 additions and 8 deletions

View file

@ -192,7 +192,7 @@ You can also set runtime templates for those found messages:
} catch (\InvalidArgumentException $e) {
$messages = $e->findMessages(
'author.username.noWhitespace' => 'Author username must not have any whitespace',
'title' => 'Article title is invalid.'
'title' => 'Article title is invalid. You provided {{input}}'
);
}

View file

@ -44,7 +44,9 @@ abstract class AbstractRule implements Validatable
$exception = $this->createException();
$input = ValidationException::stringify($input);
$name = $this->getName() ? : "\"$input\"";
$params = array_merge($extraParams, get_object_vars($this));
$params = array_merge(
$extraParams, get_object_vars($this), compact('input')
);
$exception->configure($name, $params);
if (!is_null($this->template))
$exception->setTemplate($this->template);

View file

@ -11,7 +11,7 @@
<active>yes</active>
</lead>
<date>2011-04-29</date>
<time>16:00:26</time>
<time>16:17:13</time>
<version>
<release>0.2</release>
<api>0.2</api>
@ -75,7 +75,7 @@
<file baseinstalldir="Respect/Validation" md5sum="59ffa243ffc76998c041121a67910e49" name="Exceptions/ZendException.php" role="php" />
<file baseinstalldir="Respect/Validation" md5sum="e66388c3d06a5ae83d30fa03552b0bcc" name="Rules/AbstractComposite.php" role="php" />
<file baseinstalldir="Respect/Validation" md5sum="0b4dbaf3ec8a99992122776ab0cbaf04" name="Rules/AbstractRelated.php" role="php" />
<file baseinstalldir="Respect/Validation" md5sum="538ed692251e1a2593c1cd96534b075a" name="Rules/AbstractRule.php" role="php" />
<file baseinstalldir="Respect/Validation" md5sum="ded7033264e9e3ff74cd5cf22704dc28" name="Rules/AbstractRule.php" role="php" />
<file baseinstalldir="Respect/Validation" md5sum="3b6e284d165b2934650214b9af3422dc" name="Rules/AllOf.php" role="php" />
<file baseinstalldir="Respect/Validation" md5sum="ba19b564226ca821e5ad20a094d46ae7" name="Rules/Alnum.php" role="php" />
<file baseinstalldir="Respect/Validation" md5sum="8d75ac998a6f9565d336414773137588" name="Rules/Alpha.php" role="php" />

View file

@ -118,13 +118,12 @@ class AbstractNestedExceptionTest extends \PHPUnit_Framework_TestCase
$messages = $e->findMessages(
array(
'allOf' => 'Invalid {{name}}',
'first_name.length' => 'Invalid length for {{name}}'
'first_name.length' => 'Invalid length for {{name}} {{input}}'
)
);
$this->assertEquals($messages['allOf'],
'Invalid Validation Form');
$this->assertEquals($messages['allOf'], 'Invalid Validation Form');
$this->assertEquals($messages['first_name_length'],
'Invalid length for "fiif"');
'Invalid length for "fiif" fiif');
}
}