function ListStringItem::validateAllowedValue

Same name in other branches
  1. 8.9.x core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php \Drupal\options\Plugin\Field\FieldType\ListStringItem::validateAllowedValue()
  2. 10 core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php \Drupal\options\Plugin\Field\FieldType\ListStringItem::validateAllowedValue()
  3. 11.x core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php \Drupal\options\Plugin\Field\FieldType\ListStringItem::validateAllowedValue()

Overrides ListItemBase::validateAllowedValue

File

core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php, line 68

Class

ListStringItem
Plugin implementation of the 'list_string' field type.

Namespace

Drupal\options\Plugin\Field\FieldType

Code

protected static function validateAllowedValue($option) {
    if (mb_strlen($option) > 255) {
        return new TranslatableMarkup('Allowed values list: each key must be a string at most 255 characters long.');
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.