First commit
This commit is contained in:
19
packages/mmt/ddd-shared-kernel/ValueObjects/Email.php
Normal file
19
packages/mmt/ddd-shared-kernel/ValueObjects/Email.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace MMT\DDDSharedKernel\ValueObjects;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
final class Email extends ValueObject
|
||||
{
|
||||
public function __construct(
|
||||
public private(set) string $email
|
||||
)
|
||||
{
|
||||
$this->email = trim(mb_strtolower($email));
|
||||
|
||||
if (!filter_var($this->email, FILTER_VALIDATE_EMAIL)) {
|
||||
throw new InvalidArgumentException("Invalid email format");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user