Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Email.php

function Email::__construct

Same name in this branch
  1. 11.1.x vendor/phar-io/manifest/src/values/Email.php \PharIo\Manifest\Email::__construct()

Parameters

array<string,mixed>|null $options:

self::VALIDATION_MODE_*|null $mode The pattern used to validate the email address; pass null to use the default mode configured for the EmailValidator:

string[]|null $groups:

Overrides Constraint::__construct

2 calls to Email::__construct()
EmailConstraint::__construct in core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php
Initializes the constraint with options.
EmailConstraint::__construct in core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php
Initializes the constraint with options.
1 method overrides Email::__construct()
EmailConstraint::__construct in core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php
Initializes the constraint with options.

File

vendor/symfony/validator/Constraints/Email.php, line 53

Class

Email
Validates that a value is a valid email address.

Namespace

Symfony\Component\Validator\Constraints

Code

public function __construct(?array $options = null, ?string $message = null, ?string $mode = null, ?callable $normalizer = null, ?array $groups = null, mixed $payload = null) {
    if (\is_array($options) && \array_key_exists('mode', $options) && !\in_array($options['mode'], self::VALIDATION_MODES, true)) {
        throw new InvalidArgumentException('The "mode" parameter value is not valid.');
    }
    if (null !== $mode && !\in_array($mode, self::VALIDATION_MODES, true)) {
        throw new InvalidArgumentException('The "mode" parameter value is not valid.');
    }
    parent::__construct($options, $groups, $payload);
    $this->message = $message ?? $this->message;
    $this->mode = $mode ?? $this->mode;
    $this->normalizer = $normalizer ?? $this->normalizer;
    if (self::VALIDATION_MODE_STRICT === $this->mode && !class_exists(StrictEmailValidator::class)) {
        throw new LogicException(\sprintf('The "egulias/email-validator" component is required to use the "%s" constraint in strict mode. Try running "composer require egulias/email-validator".', __CLASS__));
    }
    if (null !== $this->normalizer && !\is_callable($this->normalizer)) {
        throw new InvalidArgumentException(\sprintf('The "normalizer" option must be a valid callable ("%s" given).', get_debug_type($this->normalizer)));
    }
}
RSS feed
Powered by Drupal