EmailConstraint.php

Same filename and directory in other branches
  1. 11.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php
  2. 10 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php
  3. 9 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php
  4. 8.9.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php

Namespace

Drupal\Core\Validation\Plugin\Validation\Constraint

File

core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php

View source
<?php

namespace Drupal\Core\Validation\Plugin\Validation\Constraint;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Validation\Attribute\Constraint;
use Symfony\Component\Validator\Attribute\HasNamedArguments;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\EmailValidator;

/**
 * Count constraint.
 *
 * Overrides the symfony constraint to use the strict setting.
 */
class EmailConstraint extends Email {
  
  /**
   * {@inheritdoc}
   */
  public function __construct(?array $options = NULL, ?string $message = NULL, ?string $mode = NULL, ?callable $normalizer = NULL, ?array $groups = NULL, mixed $payload = NULL) {
    parent::__construct($options, $message, $mode, $normalizer, $groups, $payload);
    $this->mode = static::VALIDATION_MODE_STRICT;
  }
  
  /**
   * {@inheritdoc}
   */
  public function validatedBy() : string {
    return EmailValidator::class;
  }

}

Classes

Title Deprecated Summary
EmailConstraint Count constraint.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.