You are here

protected static function ListFloatItem::validateAllowedValue in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php \Drupal\options\Plugin\Field\FieldType\ListFloatItem::validateAllowedValue()
  2. 9 core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php \Drupal\options\Plugin\Field\FieldType\ListFloatItem::validateAllowedValue()

Checks whether a candidate allowed value is valid.

Parameters

string $option: The option value entered by the user.

Return value

string The error message if the specified value is invalid, NULL otherwise.

Overrides ListItemBase::validateAllowedValue

File

core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php, line 84

Class

ListFloatItem
Plugin implementation of the 'list_float' field type.

Namespace

Drupal\options\Plugin\Field\FieldType

Code

protected static function validateAllowedValue($option) {
  if (!is_numeric($option)) {
    return t('Allowed values list: each key must be a valid integer or decimal.');
  }
}