public function EmailItem::getConstraints in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php \Drupal\Core\Field\Plugin\Field\FieldType\EmailItem::getConstraints()
Gets a list of validation constraints.
Return value
array Array of constraints, each being an instance of \Symfony\Component\Validator\Constraint.
Overrides TypedData::getConstraints
File
- core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldType/ EmailItem.php, line 53
Class
- EmailItem
- Defines the 'email' field type.
Namespace
Drupal\Core\Field\Plugin\Field\FieldTypeCode
public function getConstraints() {
$constraint_manager = \Drupal::typedDataManager()
->getValidationConstraintManager();
$constraints = parent::getConstraints();
$constraints[] = $constraint_manager
->create('ComplexData', [
'value' => [
'Length' => [
'max' => Email::EMAIL_MAX_LENGTH,
'maxMessage' => t('%name: the email address can not be longer than @max characters.', [
'%name' => $this
->getFieldDefinition()
->getLabel(),
'@max' => Email::EMAIL_MAX_LENGTH,
]),
],
],
]);
return $constraints;
}