<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Formatter/isPartialStringValid(_:newEditingString:errorDescription:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFormatter(im)isPartialStringValid:newEditingString:errorDescription:"
  },
  "title" : "isPartialStringValid(_:newEditingString:errorDescription:)"
}
-->

# isPartialStringValid(_:newEditingString:errorDescription:)

Returns a Boolean value that indicates whether a partial string is valid.

```
func isPartialStringValid(_ partialString: String, newEditingString newString: AutoreleasingUnsafeMutablePointer<NSString?>?, errorDescription error: AutoreleasingUnsafeMutablePointer<NSString?>?) -> Bool
```

## Parameters

`partialString`

The text currently in a cell.

`newString`

If `partialString` needs to be modified, upon return contains the replacement string.

`error`

If non-`nil`, if validation fails contains an `NSString` object that describes the problem.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if `partialString` is an acceptable value, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

This method is invoked each time the user presses a key while the cell has the keyboard focus—it lets you verify and edit the cell text as the user types it.

In a subclass implementation, evaluate `partialString` according to the context, edit the text if necessary, and return by reference any edited string in `newString`. Return <doc://com.apple.documentation/documentation/Swift/true> if `partialString` is acceptable and <doc://com.apple.documentation/documentation/Swift/false> if `partialString` is unacceptable. If you return <doc://com.apple.documentation/documentation/Swift/false> and `newString` is `nil`, the cell displays `partialString` minus the last character typed. If you return <doc://com.apple.documentation/documentation/Swift/false>, you can also return by indirection an `NSString` object (in `error`) that explains the reason why the validation failed; the delegate (if any) of the `NSControl` object managing the cell can then respond to the failure in control:didFailToValidatePartialString:errorDescription:. The selection range will always be set to the end of the text if replacement occurs.

This method is a compatibility method. If a subclass overrides this method and does not override [`isPartialStringValid(_:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:)`](/documentation/Foundation/Formatter/isPartialStringValid(_:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:)), this method will be called as before ([`isPartialStringValid(_:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:)`](/documentation/Foundation/Formatter/isPartialStringValid(_:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:)) just calls this one by default).

---

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)