public function SocialLinkItem::getConstraints in Social Link Field 8
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
- src/
Plugin/ Field/ FieldType/ SocialLinkItem.php, line 124
Class
- SocialLinkItem
- Defines the 'social_links' entity field type.
Namespace
Drupal\social_link_field\Plugin\Field\FieldTypeCode
public function getConstraints() {
$constraint_manager = \Drupal::typedDataManager()
->getValidationConstraintManager();
$constraints = parent::getConstraints();
$constraints[] = $constraint_manager
->create('ComplexData', [
'link' => [
'Regex' => [
'message' => $this
->t('Just add the part of your profile. Do not include preceding slash.'),
// Validate not starting with "http://", "https://", "www." or "/".
'pattern' => '/^(?!(http:\\/\\/|https:\\/\\/|www.|\\/))/i',
],
],
]);
return $constraints;
}