public function EmailItem::getConstraints in Zircon Profile 8.0
Same name and namespace in other branches
- 8 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 58 - Contains \Drupal\Core\Field\Plugin\Field\FieldType\EmailItem.
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', array(
'value' => array(
'Length' => array(
'max' => Email::EMAIL_MAX_LENGTH,
'maxMessage' => t('%name: the email address can not be longer than @max characters.', array(
'%name' => $this
->getFieldDefinition()
->getLabel(),
'@max' => Email::EMAIL_MAX_LENGTH,
)),
),
),
));
return $constraints;
}