Skip to content

Commit

Permalink
Fixed some issues fiund in code review
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Dec 25, 2013
1 parent 6673522 commit d745bbf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
4 changes: 0 additions & 4 deletions Cake/ORM/Entity.php
Expand Up @@ -650,10 +650,6 @@ protected function _nestedErrors($field) {
return $errors;
}

if (is_scalar($value) || !($value instanceof self)) {
return [];
}

if ($value instanceof self) {
return $value->errors();
}
Expand Down
18 changes: 8 additions & 10 deletions Cake/ORM/Table.php
Expand Up @@ -918,15 +918,13 @@ public function validator($name = 'default', Validator $instance = null) {
return $this->_validators[$name];
}

if ($instance !== null) {
$instance->provider('table', $this);
return $this->_validators[$name] = $instance;
if ($instance === null) {
$instance = new Validator();
$instance = $this->{'validation' . ucfirst($name)}($instance);
}

$validator = new Validator;
$validator = $this->{'validation' . ucfirst($name)}($validator);
$validator->provider('table', $this);
return $this->_validators[$name] = $validator;
$instance->provider('table', $this);
return $this->_validators[$name] = $instance;
}

/**
Expand Down Expand Up @@ -1632,21 +1630,21 @@ public function validate($entity, $options = []) {
* saved.
*
* {{{
* $articles->validate([$article1, $article2]);
* $articles->validateMany([$article1, $article2]);
* }}}
*
* You can specify which validation set to use using the options array:
*
* {{{
* $users->validate([$user1, $user2], ['validate' => 'forSignup']);
* $users->validateMany([$user1, $user2], ['validate' => 'forSignup']);
* }}}
*
* By default all the associations on this table will be validated if they can
* be found in the passed entities. You can limit which associations are built,
* or include deeper associations using the options parameter
*
* {{{
* $articles->validate([$article1, $article2], [
* $articles->validateMany([$article1, $article2], [
* 'associated' => [
* 'Tags',
* 'Comments' => [
Expand Down

0 comments on commit d745bbf

Please sign in to comment.