function TelephoneItem::getConstraints
Same name in other branches
- 9 core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php \Drupal\telephone\Plugin\Field\FieldType\TelephoneItem::getConstraints()
- 10 core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php \Drupal\telephone\Plugin\Field\FieldType\TelephoneItem::getConstraints()
- 11.x core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php \Drupal\telephone\Plugin\Field\FieldType\TelephoneItem::getConstraints()
Overrides TypedData::getConstraints
File
-
core/
modules/ telephone/ src/ Plugin/ Field/ FieldType/ TelephoneItem.php, line 60
Class
- TelephoneItem
- Plugin implementation of the 'telephone' field type.
Namespace
Drupal\telephone\Plugin\Field\FieldTypeCode
public function getConstraints() {
$constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
$constraints = parent::getConstraints();
$max_length = 256;
$constraints[] = $constraint_manager->create('ComplexData', [
'value' => [
'Length' => [
'max' => $max_length,
'maxMessage' => t('%name: the telephone number may not be longer than @max characters.', [
'%name' => $this->getFieldDefinition()
->getLabel(),
'@max' => $max_length,
]),
],
],
]);
return $constraints;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.