ldc-boutique-cnc-sable/app/Actions/Customers/RegisterCustomerInput.php

43 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Actions\Customers;
use App\Contracts\ActionInput;
use Domain\Models\ValueObjects\Code;
use Domain\Models\ValueObjects\Email;
use Domain\Models\ValueObjects\Matricule;
use Domain\Models\ValueObjects\PhoneNumber;
use Webmozart\Assert\Assert;
final readonly class RegisterCustomerInput implements ActionInput
{
public function __construct(
public Matricule $matricule,
public Code $code,
public string $firstname,
public string $lastname,
public Email $email,
public string $password,
public \DateTimeImmutable $birthDate,
public ?PhoneNumber $phone,
public ?string $address,
public string $postcode,
public string $city,
public bool $optIn = false,
) {
Assert::stringNotEmpty(trim($this->firstname));
Assert::maxLength($this->firstname, 255);
Assert::stringNotEmpty(trim($this->lastname));
Assert::maxLength($this->lastname, 255);
Assert::stringNotEmpty(trim($this->password));
Assert::stringNotEmpty(trim($this->postcode));
Assert::maxLength($this->postcode, 20);
Assert::stringNotEmpty(trim($this->city));
Assert::maxLength($this->city, 255);
if ($this->address !== null) {
Assert::maxLength($this->address, 255);
}
}
}