ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
class.ilGroupNameAsMailValidator.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
25 
29  public function __construct(protected string $host, ?callable $group_name_check_callable = null)
30  {
31  $this->group_name_check_callable = $group_name_check_callable ?? static fn(string $group_name): bool => ilUtil::groupNameExists($group_name);
32  }
33 
37  public function validate(ilMailAddress $address): bool
38  {
39  $group_name = substr($address->getMailbox(), 1);
40 
42  return $func($group_name) && $this->isHostValid($address->getHost());
43  }
44 
45  private function isHostValid(string $host): bool
46  {
47  return ($host === $this->host || $host === '');
48  }
49 }
__construct(protected string $host, ?callable $group_name_check_callable=null)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
validate(ilMailAddress $address)
Validates if the given address contains a valid group name to send an email.
static groupNameExists(string $a_group_name, ?int $a_id=null)
checks if group name already exists.