You are here

class UserMailRequired in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/user/src/Plugin/Validation/Constraint/UserMailRequired.php \Drupal\user\Plugin\Validation\Constraint\UserMailRequired
  2. 9 core/modules/user/src/Plugin/Validation/Constraint/UserMailRequired.php \Drupal\user\Plugin\Validation\Constraint\UserMailRequired

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.

Plugin annotation


@Constraint(
  id = "UserMailRequired",
  label = @Translation("User email required", context = "Validation")
)

Hierarchy

  • class \Drupal\user\Plugin\Validation\Constraint\UserMailRequired extends \Symfony\Component\Validator\Constraint

Expanded class hierarchy of UserMailRequired

1 file declares its use of UserMailRequired
UserMailRequiredValidatorTest.php in core/modules/user/tests/src/Unit/Plugin/Validation/Constraint/UserMailRequiredValidatorTest.php
1 string reference to 'UserMailRequired'
User::baseFieldDefinitions in core/modules/user/src/Entity/User.php

File

core/modules/user/src/Plugin/Validation/Constraint/UserMailRequired.php, line 19

Namespace

Drupal\user\Plugin\Validation\Constraint
View source
class UserMailRequired extends Constraint {

  /**
   * 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.';

}

Members

Namesort descending Modifiers Type Description Overrides
UserMailRequired::$message public property Violation message. Use the same message as FormValidator.