add null guards in create node use case
This commit is contained in:
parent
23f4e70e57
commit
ff721d9137
1 changed files with 9 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Node\UseCases;
|
||||
|
||||
use App\Exceptions\BadRequestException;
|
||||
use App\Node\Node;
|
||||
use App\Node\CreateNodeDto;
|
||||
use App\Node\NodeRepository;
|
||||
|
|
@ -20,6 +21,14 @@ class CreateNode
|
|||
*/
|
||||
public function execute(CreateNodeRequest $request): Node
|
||||
{
|
||||
if ($request->textId === null) {
|
||||
throw new BadRequestException('textId is required');
|
||||
}
|
||||
|
||||
if ($request->title === null) {
|
||||
throw new BadRequestException('title is required');
|
||||
}
|
||||
|
||||
$textId = $request->textId;
|
||||
$text = $this->textRepo->find($textId);
|
||||
if ($text === null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue