---
title: "isValid(within:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/range/isvalid(within:)-2fba2"
---

# isValid(within:)

Indicates whether the range 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 range.

## Return Value

Return Value true when the range is valid for use with the provided attributed string; otherwise, false. A range is valid if its lower and upper bounds are each either valid in the attributed string or equivalent to the string’s endIndex.
