Get the values of a checkbox field in node when evaluating in block condition plugin
Original Answer

The proper way to access field values is $entity-&gt;get('my_field')-&gt;getValue() in your case this will return an array like:

Array(
  0 =&gt; Array(
    'value' =&gt; 'value1'
  ),
  1 =&gt; Array(
    'value' =&gt; 'value2'
  ),
  2 =&gt; Array(
    'value' =&gt; 'value3'
  ),
  // And so on as many values your field has.
)


Also you can check if the field is empty by calling $entity-&gt;get('my_field')-&gt;isEmpty(). Calling only your field like $entity-&gt;get('my_field') will NOT return the field value but the field instance. Calling for an unexisting field will throw a runtime exception.

UPDATE

To check if the value exists you can either iterate over the array or do something like this

$arr = [
  0 =&gt; [
    'value' =&gt; 'value1',
  ],
  1 =&gt; [
    'value' =&gt; 'value2',
  ],
  2 =&gt; [
    'value' =&gt; 'value3',
  ],
];

$arr = array_map(function ($v) {
  return $v['value'];
}, $arr);

assert(in_array('value2', $arr, TRUE), 'Assert that contains value2');
assert(in_array('other', $arr, TRUE), 'Assert that contains other. This will fail');


You can try it here.