Skip to content

Commit

Permalink
Improving error message when the funciton is no callable in the provider
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Nov 20, 2013
1 parent 27728be commit 21129a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cake/Test/TestCase/Validation/ValidationRuleTest.php
Expand Up @@ -80,7 +80,7 @@ public function testCustomMethods() {
* Make sure errors are triggered when validation is missing.
*
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Invalid validation callable
* @expectedExceptionMessage Unable to call method totallyMissing in default provider
* @return void
*/
public function testCustomMethodMissingError() {
Expand Down
5 changes: 4 additions & 1 deletion Cake/Validation/ValidationRule.php
Expand Up @@ -117,7 +117,10 @@ public function process($data, $providers, $newRecord) {
}

if (!$isCallable) {
throw new \InvalidArgumentException('Invalid validation callable');
$message = 'Unable to call method %s in %s provider';
throw new \InvalidArgumentException(
sprintf($message, $this->_rule, $this->_provider)
);
}

if ($this->_pass) {
Expand Down

0 comments on commit 21129a8

Please sign in to comment.