Skip to content
Permalink
Browse files

Make validation failure rule errors more descriptive.

Include quotes around missing things so even empty values are clearer.

Refs #3920
  • Loading branch information...
markstory committed Jul 11, 2014
1 parent 160f56c commit 27823012e7aee88690f48adbd0420279bafa9804
Showing with 4 additions and 4 deletions.
  1. +2 −2 src/Validation/ValidationRule.php
  2. +2 −2 tests/TestCase/Validation/ValidationRuleTest.php
@@ -123,9 +123,9 @@ public function process($value, array $providers, array $context = []) {
}
if (!$isCallable) {
$message = 'Unable to call method %s in %s provider';
$message = 'Unable to call method "%s" in "%s" provider for field "%s"';
throw new \InvalidArgumentException(
sprintf($message, $this->_rule, $this->_provider)
sprintf($message, $this->_rule, $this->_provider, $context['field'])
);
}
@@ -77,7 +77,7 @@ public function testCustomMethods() {
* Make sure errors are triggered when validation is missing.
*
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Unable to call method totallyMissing in default provider
* @expectedExceptionMessage Unable to call method "totallyMissing" in "default" provider for field "test"
* @return void
*/
public function testCustomMethodMissingError() {
@@ -86,7 +86,7 @@ public function testCustomMethodMissingError() {
$providers = ['default' => $this];
$Rule = new ValidationRule($def);
$Rule->process($data, $providers, ['newRecord' => true]);
$Rule->process($data, $providers, ['newRecord' => true, 'field' => 'test']);
}
/**

0 comments on commit 2782301

Please sign in to comment.
You can’t perform that action at this time.