add null guard in create text use case
This commit is contained in:
parent
ab023315a9
commit
f77101e4e9
1 changed files with 5 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Text\UseCases;
|
||||
|
||||
use App\Exceptions\BadRequestException;
|
||||
use App\Text\Text;
|
||||
use App\Text\CreateTextDto;
|
||||
use App\Text\TextRepository;
|
||||
|
|
@ -17,6 +18,10 @@ class CreateText
|
|||
|
||||
public function execute(CreateTextRequest $request): Text
|
||||
{
|
||||
if ($request->name === null) {
|
||||
throw new BadRequestException('name is required');
|
||||
}
|
||||
|
||||
$text = $this->textRepo->create(new CreateTextDto(
|
||||
name: $request->name,
|
||||
));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue