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

Breadcrumb

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

class Email

Same name in this branch
  1. 11.1.x vendor/phar-io/manifest/src/values/Email.php \PharIo\Manifest\Email
  2. 11.1.x vendor/symfony/mime/Email.php \Symfony\Component\Mime\Email
  3. 11.1.x core/lib/Drupal/Core/TypedData/Plugin/DataType/Email.php \Drupal\Core\TypedData\Plugin\DataType\Email
  4. 11.1.x core/lib/Drupal/Core/Render/Element/Email.php \Drupal\Core\Render\Element\Email
  5. 11.1.x core/modules/field/src/Plugin/migrate/field/Email.php \Drupal\field\Plugin\migrate\field\Email

Validates that a value is a valid email address.

@author Bernhard Schussek <bschussek@gmail.com>

Hierarchy

  • class \Symfony\Component\Validator\Constraint
    • class \Symfony\Component\Validator\Constraints\Email extends \Symfony\Component\Validator\Constraint

Expanded class hierarchy of Email

1 file declares its use of Email
EmailConstraint.php in core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php
26 string references to 'Email'
AccountSettingsForm::buildForm in core/modules/user/src/AccountSettingsForm.php
Form constructor.
AuthorElement::getEmail in vendor/phar-io/manifest/src/xml/AuthorElement.php
AuthorElement::hasEMail in vendor/phar-io/manifest/src/xml/AuthorElement.php
claro_preprocess_input in core/themes/claro/claro.theme
Implements template_preprocess_HOOK() for input.
CommentForm::form in core/modules/comment/src/CommentForm.php
Gets the actual form array to be built.

... See full list

File

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

Namespace

Symfony\Component\Validator\Constraints
View source
class Email extends Constraint {
    public const VALIDATION_MODE_HTML5_ALLOW_NO_TLD = 'html5-allow-no-tld';
    public const VALIDATION_MODE_HTML5 = 'html5';
    public const VALIDATION_MODE_STRICT = 'strict';
    public const INVALID_FORMAT_ERROR = 'bd79c0ab-ddba-46cc-a703-a7a4b08de310';
    public const VALIDATION_MODES = [
        self::VALIDATION_MODE_HTML5_ALLOW_NO_TLD,
        self::VALIDATION_MODE_HTML5,
        self::VALIDATION_MODE_STRICT,
    ];
    protected const ERROR_NAMES = [
        self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR',
    ];
    public string $message = 'This value is not a valid email address.';
    public ?string $mode = null;
    
    /** @var callable|null */
    public $normalizer;
    
    /**
     * @param array<string,mixed>|null     $options
     * @param self::VALIDATION_MODE_*|null $mode    The pattern used to validate the email address; pass null to use the default mode configured for the EmailValidator
     * @param string[]|null                $groups
     */
    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)));
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
Constraint::$groups public property The groups that the constraint belongs to.
Constraint::$payload public property Domain-specific data attached to a constraint.
Constraint::addImplicitGroupName public function Adds the given group if this constraint is in the Default group. 2
Constraint::CLASS_CONSTRAINT public constant Marks a constraint that can be put onto classes.
Constraint::DEFAULT_GROUP public constant The name of the group given to all constraints with no explicit group.
Constraint::getDefaultOption public function Returns the name of the default option. 28
Constraint::getErrorName public static function Returns the name of the given error code.
Constraint::getRequiredOptions public function Returns the name of the required options. 22
Constraint::getTargets public function Returns whether the constraint can be put onto classes, properties or
both.
8
Constraint::normalizeOptions protected function
Constraint::PROPERTY_CONSTRAINT public constant Marks a constraint that can be put onto properties.
Constraint::validatedBy public function Returns the name of the class that validates this constraint. 9
Constraint::__get public function Returns the value of a lazily initialized option. 2
Constraint::__isset public function 1
Constraint::__set public function Sets the value of a lazily initialized option. 1
Constraint::__sleep public function Optimizes the serialized value to minimize storage space.
Email::$message public property
Email::$mode public property
Email::$normalizer public property @var callable|null
Email::ERROR_NAMES protected constant Maps error codes to the names of their constants. Overrides Constraint::ERROR_NAMES
Email::INVALID_FORMAT_ERROR public constant
Email::VALIDATION_MODES public constant
Email::VALIDATION_MODE_HTML5 public constant
Email::VALIDATION_MODE_HTML5_ALLOW_NO_TLD public constant
Email::VALIDATION_MODE_STRICT public constant
Email::__construct public function Overrides Constraint::__construct 1
RSS feed
Powered by Drupal