<!--
{
  "availability" : [
    "macOS: 10.12.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SafariServices",
  "identifier" : "/documentation/SafariServices/SFSafariExtensionHandling/validateToolbarItem(in:validationHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Safari Services"
    ],
    "preciseIdentifier" : "c:objc(pl)SFSafariExtensionHandling(im)validateToolbarItemInWindow:validationHandler:"
  },
  "title" : "validateToolbarItem(in:validationHandler:)"
}
-->

# validateToolbarItem(in:validationHandler:)

Determines if a toolbar menu item should be enabled or have badge text when browser state changes.

```
optional func validateToolbarItem(in window: SFSafariWindow, validationHandler: @escaping (Bool, String) -> Void)
```

## Parameters

`window`

The window containing the clicked toolbar item.

`validationHandler`

A code block used to set the state of the toolbar item.

## Discussion

This method is called by the [`setToolbarItemsNeedUpdate()`](/documentation/SafariServices/SFSafariApplication/setToolbarItemsNeedUpdate()) method or when Safari’s state changes in a way that may affect the toolbar item’s enabled or badge state. Your handler should decide whether the toolbar menu should be enabled and whether it should have any badge text, and then call the `validationHandler` block to update the toolbar item state.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)