---
title: "isValid(within:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/attributedstring/index/isvalid(within:)-8fw50"
---

# isValid(within:)

Indicates whether the index is valid for use with the provided attributed string.

## Declaration

```swift
func isValid(within text: some AttributedStringProtocol) -> Bool
```

## Parameters

- `text`: An attributed string used to validate the index.

## Return Value

Return Value true when the index is valid for use with the provided attributed string; otherwise, false. An index is valid if it is both within the bounds of the attributed string and was produced from the provided string without any intermediate mutations.
