39 lines
1.4 KiB
PHP
39 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Actions\Shops;
|
|
|
|
use App\Contracts\ActionInput;
|
|
use Domain\Models\ValueObjects\Coordinates;
|
|
use Domain\Models\ValueObjects\PhoneNumber;
|
|
use Webmozart\Assert\Assert;
|
|
|
|
final readonly class CreateShopInput implements ActionInput
|
|
{
|
|
public function __construct(
|
|
public string $name,
|
|
public string $address,
|
|
public string $postcode,
|
|
public string $city,
|
|
public ?PhoneNumber $phone,
|
|
public ?Coordinates $coordinates,
|
|
public bool $default,
|
|
) {
|
|
$trimmedName = trim($this->name);
|
|
Assert::stringNotEmpty($trimmedName, 'Shop name cannot be empty.');
|
|
Assert::maxLength($trimmedName, 255, 'Shop name cannot exceed 255 characters.');
|
|
|
|
$trimmedAddress = trim($this->address);
|
|
Assert::stringNotEmpty($trimmedAddress, 'Shop address cannot be empty.');
|
|
Assert::maxLength($trimmedAddress, 255, 'Shop address cannot exceed 255 characters.');
|
|
|
|
$trimmedPostcode = trim($this->postcode);
|
|
Assert::stringNotEmpty($trimmedPostcode, 'Shop postcode cannot be empty.');
|
|
Assert::maxLength($trimmedPostcode, 255, 'Shop postcode cannot exceed 255 characters.');
|
|
|
|
$trimmedCity = trim($this->city);
|
|
Assert::stringNotEmpty($trimmedCity, 'Shop city cannot be empty.');
|
|
Assert::maxLength($trimmedCity, 255, 'Shop city cannot exceed 255 characters.');
|
|
}
|
|
}
|