You are here

protected static function SmartDateListItemBase::validateAllowedValue in Smart Date 3.3.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldType/SmartDateListItemBase.php \Drupal\smart_date\Plugin\Field\FieldType\SmartDateListItemBase::validateAllowedValue()
  2. 8 src/Plugin/Field/FieldType/SmartDateListItemBase.php \Drupal\smart_date\Plugin\Field\FieldType\SmartDateListItemBase::validateAllowedValue()
  3. 3.x src/Plugin/Field/FieldType/SmartDateListItemBase.php \Drupal\smart_date\Plugin\Field\FieldType\SmartDateListItemBase::validateAllowedValue()
  4. 3.0.x src/Plugin/Field/FieldType/SmartDateListItemBase.php \Drupal\smart_date\Plugin\Field\FieldType\SmartDateListItemBase::validateAllowedValue()
  5. 3.1.x src/Plugin/Field/FieldType/SmartDateListItemBase.php \Drupal\smart_date\Plugin\Field\FieldType\SmartDateListItemBase::validateAllowedValue()
  6. 3.2.x src/Plugin/Field/FieldType/SmartDateListItemBase.php \Drupal\smart_date\Plugin\Field\FieldType\SmartDateListItemBase::validateAllowedValue()
  7. 3.4.x src/Plugin/Field/FieldType/SmartDateListItemBase.php \Drupal\smart_date\Plugin\Field\FieldType\SmartDateListItemBase::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

src/Plugin/Field/FieldType/SmartDateListItemBase.php, line 24

Class

SmartDateListItemBase
Abstract clss meant to expose parse and related functions for lists.

Namespace

Drupal\smart_date\Plugin\Field\FieldType

Code

protected static function validateAllowedValue($option) {

  // Verify that the duration option is either custom or an integer.
  if ($option != 'custom' && !preg_match('/^-?\\d+$/', $option)) {
    return t('Allowed values list: keys must be integers or "custom".');
  }
}