Implements hook_field_validate().
Possible error codes:
function options_field_validate(EntityInterface $entity = NULL, $field, $instance, $langcode, $items, &$errors) {
$allowed_values = options_allowed_values($field, $instance, $entity);
foreach ($items as $delta => $item) {
if (!empty($item['value'])) {
if (!empty($allowed_values) && !isset($allowed_values[$item['value']])) {
$errors[$field['field_name']][$langcode][$delta][] = array(
'error' => 'list_illegal_value',
'message' => t('%name: illegal value.', array(
'%name' => $instance['label'],
)),
);
}
}
}
}