You are here

protected static function ImageStyleItem::validateAllowedValue in Field Image Style 8

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

1 call to ImageStyleItem::validateAllowedValue()
ImageStyleItem::validateAllowedValues in src/Plugin/Field/FieldType/ImageStyleItem.php
#element_validate callback for options field allowed values.

File

src/Plugin/Field/FieldType/ImageStyleItem.php, line 151

Class

ImageStyleItem
Plugin implementation of the 'image_style' field type.

Namespace

Drupal\field_image_style\Plugin\Field\FieldType

Code

protected static function validateAllowedValue($option) {
  $image_style_options = image_style_options(FALSE);
  if (!array_key_exists($option, $image_style_options)) {
    return t('Image style @name does\'nt exist.', array(
      '@name' => $option,
    ));
  }
}