add null guard in create user use case
This commit is contained in:
parent
e2c220e0ee
commit
90a9002df0
1 changed files with 5 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\User\UseCases;
|
||||
|
||||
use App\Exceptions\BadRequestException;
|
||||
use App\User\UserRepository;
|
||||
use App\ValueObjects\EmailAddress;
|
||||
|
||||
|
|
@ -13,6 +14,10 @@ class CreateUser
|
|||
|
||||
public function execute(CreateUserRequest $dto): void
|
||||
{
|
||||
if ($dto->email === null) {
|
||||
throw new BadRequestException('email is required');
|
||||
}
|
||||
|
||||
$this->userRepo->create(new CreateUserDto(
|
||||
email: new EmailAddress($dto->email),
|
||||
));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue