Remove page from cache based on block

Hi,

I am currently excluding pages from the cache like this:

'cache' => [
      'pages' => [
          'active' => true,
          'ignore' => function ($page) {
            return in_array($page->id(), ['contact']);
          }
      ]
    ]

Which works great. I have now made a “Contact Form” block type using Blocks, which are part of a Page Builder setup. I now need to exclude pages from the cache where this has been used, rather than based on the page id as I have done above. I am not really sure where to start with this, has anyone done something similar?

Should be something like

$page->fieldname()->toBlocks()->filterBy('type', $type)->isNotEmpty();