UserMailRequired.php
Same filename and directory in other branches
- 11.x core/modules/user/src/Plugin/Validation/Constraint/UserMailRequired.php
- 10 core/modules/user/src/Plugin/Validation/Constraint/UserMailRequired.php
- 9 core/modules/user/src/Plugin/Validation/Constraint/UserMailRequired.php
- 8.9.x core/modules/user/src/Plugin/Validation/Constraint/UserMailRequired.php
Namespace
Drupal\user\Plugin\Validation\ConstraintFile
-
core/
modules/ user/ src/ Plugin/ Validation/ Constraint/ UserMailRequired.php
View source
<?php
namespace Drupal\user\Plugin\Validation\Constraint;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Validation\Attribute\Constraint;
use Symfony\Component\Validator\Attribute\HasNamedArguments;
use Symfony\Component\Validator\Constraint as SymfonyConstraint;
/**
* Checks if the user's email address is provided if required.
*
* The user mail field is NOT required if account originally had no mail set
* and the user performing the edit has 'administer users' permission.
* This allows users without email address to be edited and deleted.
*/
class UserMailRequired extends SymfonyConstraint {
/**
* Violation message. Use the same message as FormValidator.
*
* Note that the name argument is not sanitized so that translators only have
* one string to translate. The name is sanitized in self::validate().
*
* @var string
*/
public $message = '@name field is required.';
public function __construct(mixed $options = NULL, ?string $message = NULL, ?array $groups = NULL, mixed $payload = NULL) {
parent::__construct($options, $groups, $payload);
$this->message = $message ?? $this->message;
}
}
Classes
| Title | Deprecated | Summary |
|---|---|---|
| UserMailRequired | Checks if the user's email address is provided if required. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.