Skip to content

Commit

Permalink
adding check for the validate* methods into the verify() handling, if…
Browse files Browse the repository at this point in the history
… they exist
  • Loading branch information
Chris Cornutt committed Feb 3, 2015
1 parent b2a8280 commit 9930c81
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Modler/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ public function verify(array $ignore = array())
if ((isset($config['required']) && $config['required'] === true) && !isset($this->values[$name])) {
throw new \InvalidArgumentException('Property "'.$name.'" is required!');
}
$validateMethod = 'validate'.ucwords(strtolower($name));
if (method_exists($this, $validateMethod) && isset($this->values[$name])) {
if ($this->$validateMethod($this->values[$name]) === false) {
throw new \InvalidArgumentException('Invalid value for property "'.$name.'"!');
}
}
}
return true;
}
Expand Down

0 comments on commit 9930c81

Please sign in to comment.