How to use an IF statement on Boolean values in .twig?

I’ve created a Boolean field (field_warn) with the settings listed below. I expect the message to display if On (true) or display nothing if Off, but the message is ALWAYS displayed regardless if the box is checked (on) or unchecked (off). Any ideas why?

  • Allowed number of values of 1
  • “On” label: On
  • “Off” label: Off

In my .twig file:

{% if content.field_warn == true %}
   <div aria-label="message">
    This is a warning.
   </div>
{% endif %}

Reference: http://twig.sensiolabs.org/doc/2.x/tags/if.html

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/22/feed