public function JSONItem::getMaxLength in JSON Field 8
Calculates max character length for a field value.
1 call to JSONItem::getMaxLength()
- JSONItem::getConstraints in src/
Plugin/ Field/ FieldType/ JSONItem.php - Gets a list of validation constraints.
File
- src/
Plugin/ Field/ FieldType/ JSONItem.php, line 125
Class
- JSONItem
- Plugin implementation of the 'JSON' field type.
Namespace
Drupal\json_field\Plugin\Field\FieldTypeCode
public function getMaxLength() {
$size = $this
->getSetting('size');
switch ($size) {
// Varchar columns.
case static::SIZE_SMALL:
return static::SIZE_SMALL;
// Text columns use utf8mb4 so the maximum length is size / 4.
default:
return floor($size / 4);
}
}