<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSToolbarItemValidation",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSToolbarItemValidation"
  },
  "title" : "NSToolbarItemValidation"
}
-->

# NSToolbarItemValidation

Validation of a toolbar item.

```
protocol NSToolbarItemValidation : NSObjectProtocol
```

## Overview

A toolbar item with a valid target and action is enabled by default. To allow a toolbar item to be disabled in certain situations, a toolbar item’s target can implement the [`validateToolbarItem(_:)`](/documentation/AppKit/NSToolbarItemValidation/validateToolbarItem(_:)) method.

> Note:
> The ``doc://com.apple.appkit/documentation/AppKit/NSToolbarItem`` ``doc://com.apple.appkit/documentation/AppKit/NSToolbarItem/validate()`` method is called only if the item’s target has a valid action defined on its target and if the item isn’t a custom view item. If you want to validate a custom view item, then you have to subclass ``doc://com.apple.appkit/documentation/AppKit/NSToolbarItem`` and override ``doc://com.apple.appkit/documentation/AppKit/NSToolbarItem/validate()``.

## Topics

### Enabling and disabling toolbar items

[`func validateToolbarItem(NSToolbarItem) -> Bool`](/documentation/AppKit/NSToolbarItemValidation/validateToolbarItem(_:))

Determines whether to enable or disable the toolbar item.

## Relationships

### Inherits From

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

---

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)