public function SoundCloudItem::getConstraints in SoundCloud 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/ SoundCloudItem.php, line 73
Class
- SoundCloudItem
- Plugin implementation of the 'soundcloud' field type.
Namespace
Drupal\soundcloudfield\Plugin\Field\FieldTypeCode
public function getConstraints() {
$constraint_manager = \Drupal::typedDataManager()
->getValidationConstraintManager();
$constraints = parent::getConstraints();
$max_length = 512;
$constraints[] = $constraint_manager
->create('ComplexData', array(
'url' => array(
'Length' => array(
'max' => $max_length,
'maxMessage' => $this
->t('%name: the SoundCloud URL may not be longer than @max characters.', array(
'%name' => $this
->getFieldDefinition()
->getLabel(),
'@max' => $max_length,
)),
),
),
));
return $constraints;
}