Skip to content

Commit

Permalink
feat(users): add email to MergeIdentifier object
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioturdo committed Apr 3, 2024
1 parent 51b1810 commit a2d42cf
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Object/Users/MergeIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ class MergeIdentifier extends BaseObject

public ?UserAlias $user_alias = null;

public ?string $email = null;

/** @var ?string[] */
public ?array $prioritization = null;

public function validate(bool $strict): void
{
parent::validate($strict);

if (null === $this->external_id && null === $this->user_alias) {
throw new ValidationException('One of "external_id" or "user_alias" fields is required');
if (null === $this->external_id && null === $this->user_alias && null === $this->email) {
throw new ValidationException('One of "external_id", "user_alias" or "email" fields is required');
}

if (null !== $this->external_id && null !== $this->user_alias) {
throw new ValidationException('Only one of "external_id" and "user_alias" fields must be set');
if (\count(\array_filter([$this->external_id, $this->user_alias, $this->email])) > 1) {
throw new ValidationException('Only one of "external_id", "user_alias" and "email" fields must be set');
}

$this->user_alias?->validate($strict);
Expand Down

0 comments on commit a2d42cf

Please sign in to comment.