From 1f76fc08b69b3be753e4939df3dc947c2fb95a92 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sun, 19 Apr 2026 23:10:10 +0300 Subject: [PATCH] add null guards in bulk create nodes use case --- app/Node/UseCases/BulkCreateNodes.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/Node/UseCases/BulkCreateNodes.php b/app/Node/UseCases/BulkCreateNodes.php index 1ca322d..d4b124b 100644 --- a/app/Node/UseCases/BulkCreateNodes.php +++ b/app/Node/UseCases/BulkCreateNodes.php @@ -2,6 +2,7 @@ namespace App\Node\UseCases; +use App\Exceptions\BadRequestException; use App\Node\CreateNodeDto; use App\Node\Node; use App\Node\NodeRepository; @@ -21,6 +22,22 @@ class BulkCreateNodes */ public function execute(BulkCreateNodesRequest $request): array { + if ($request->textId === null) { + throw new BadRequestException('textId is required'); + } + + if ($request->parentNodeId === null) { + throw new BadRequestException('parentNodeId is required'); + } + + if ($request->titlePrefix === null) { + throw new BadRequestException('titlePrefix is required'); + } + + if ($request->count === null) { + throw new BadRequestException('count is required'); + } + $text = $this->textRepo->find($request->textId); if ($text === null) { throw new DomainException("Text with id: {$request->textId} doesnt exist");