<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/NSObject-swift.class/validateValue(_:forKeyPath:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Objective-C Runtime",
      "ObjectiveC"
    ],
    "preciseIdentifier" : "c:objc(cs)NSObject(im)validateValue:forKeyPath:error:"
  },
  "title" : "validateValue(_:forKeyPath:)"
}
-->

# validateValue(_:forKeyPath:)

Indicates whether the value specified by a given pointer is not valid for a given key path relative to the receiver.

```
func validateValue(_ ioValue: AutoreleasingUnsafeMutablePointer<AnyObject?>, forKeyPath inKeyPath: String) throws
```

## Parameters

`ioValue`

A pointer to a new value for the property identified by `inKeyPath`. This method may modify or replace the value in order to make it valid.

`inKeyPath`

The name of one of the receiver’s properties. The key path must specify an attribute or a to-one relationship. The key path has the form `relationship``.``property` (with one or more relationships); for example `department.name` or `department.manager.lastName`.

## Discussion

In Swift, this method throws an error if the value isn’t valid.  In Objective-C, it returns a Boolean value.

The default implementation of this method gets the destination object for each relationship using [`value(forKey:)`](/documentation/ObjectiveC/NSObject-swift.class/value(forKey:)) and returns the result of calling the [`validateValue(_:forKey:)`](/documentation/ObjectiveC/NSObject-swift.class/validateValue(_:forKey:)) method for the property.

---

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)