Skip to content

Commit d745bbf

Browse files
committed
Fixed some issues fiund in code review
1 parent 6673522 commit d745bbf

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

Cake/ORM/Entity.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,6 @@ protected function _nestedErrors($field) {
650650
return $errors;
651651
}
652652

653-
if (is_scalar($value) || !($value instanceof self)) {
654-
return [];
655-
}
656-
657653
if ($value instanceof self) {
658654
return $value->errors();
659655
}

Cake/ORM/Table.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -918,15 +918,13 @@ public function validator($name = 'default', Validator $instance = null) {
918918
return $this->_validators[$name];
919919
}
920920

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

926-
$validator = new Validator;
927-
$validator = $this->{'validation' . ucfirst($name)}($validator);
928-
$validator->provider('table', $this);
929-
return $this->_validators[$name] = $validator;
926+
$instance->provider('table', $this);
927+
return $this->_validators[$name] = $instance;
930928
}
931929

932930
/**
@@ -1632,21 +1630,21 @@ public function validate($entity, $options = []) {
16321630
* saved.
16331631
*
16341632
* {{{
1635-
* $articles->validate([$article1, $article2]);
1633+
* $articles->validateMany([$article1, $article2]);
16361634
* }}}
16371635
*
16381636
* You can specify which validation set to use using the options array:
16391637
*
16401638
* {{{
1641-
* $users->validate([$user1, $user2], ['validate' => 'forSignup']);
1639+
* $users->validateMany([$user1, $user2], ['validate' => 'forSignup']);
16421640
* }}}
16431641
*
16441642
* By default all the associations on this table will be validated if they can
16451643
* be found in the passed entities. You can limit which associations are built,
16461644
* or include deeper associations using the options parameter
16471645
*
16481646
* {{{
1649-
* $articles->validate([$article1, $article2], [
1647+
* $articles->validateMany([$article1, $article2], [
16501648
* 'associated' => [
16511649
* 'Tags',
16521650
* 'Comments' => [

0 commit comments

Comments
 (0)