EmailConstraint.php

Same filename in other branches
  1. 8.9.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php
  2. 10 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php
  3. 11.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 Symfony\Component\Validator\Constraints\Email;

/**
 * Count constraint.
 *
 * Overrides the symfony constraint to use the strict setting.
 *
 * @Constraint(
 *   id = "Email",
 *   label = @Translation("Email", context = "Validation")
 * )
 */
class EmailConstraint extends Email {
    
    /**
     * {@inheritdoc}
     */
    public function __construct($options = []) {
        $options += [
            'mode' => 'strict',
        ];
        parent::__construct($options);
    }
    
    /**
     * {@inheritdoc}
     */
    public function validatedBy() {
        return '\\Symfony\\Component\\Validator\\Constraints\\EmailValidator';
    }

}

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.