Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Fix ->validationErrors->count() when the object is null #225

Merged
merged 2 commits into from
May 10, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/LaravelBook/Ardent/Ardent.php
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,9 @@ public function validate(array $rules = array(), array $customMessages = array()

if ($success) {
// if the model is valid, unset old errors
if ($this->validationErrors->count() > 0) {
if($this->validationErrors === null){
$this->validationErrors = new MessageBag;
}elseif($this->validationErrors->count() > 0) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would look cleaner if these two conditions were merged.

$this->validationErrors = new MessageBag; is executed in both cases anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, fix spacing. Would be nice if you follow PSR-2: http://www.php-fig.org/psr/psr-2/#5.1.-if,-elseif,-else

$this->validationErrors = new MessageBag;
}
} else {
Expand Down