test that carrier email is unique
This commit is contained in:
parent
908baee2a7
commit
2d8bca1a07
4 changed files with 60 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ namespace FreightQuote\Carrier\UseCases;
|
|||
|
||||
use FreightQuote\Carrier\Carrier;
|
||||
use FreightQuote\Carrier\CarrierRepository;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class CreateCarrier
|
||||
{
|
||||
|
|
@ -13,6 +14,9 @@ class CreateCarrier
|
|||
|
||||
public function execute(CreateCarrierRequest $dto): Carrier
|
||||
{
|
||||
if ($this->carrierRepo->findByEmail($dto->email) !== null) {
|
||||
throw new InvalidArgumentException();
|
||||
}
|
||||
$carrier = new Carrier(
|
||||
null,
|
||||
$dto->email,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue