---
title: "init(for:values:default:)"
framework: swiftui
role: symbol
role_heading: Initializer
path: "swiftui/attributedtextformatting/valueconstraint/init(for:values:default:)"
---

# init(for:values:default:)

Create a definition that constrains an attribute’s value to a defined set of allowed values.

## Declaration

```swift
init(for attribute: AttributeKey.Type, values allowedValues: Set<AttributeKey.Value?>, default defaultValue: AttributeKey.Value?)
```

## Parameters

- `allowedValues`: A set of values that are permitted.
- `defaultValue`: A single permitted value that is used to replace any values that are not in the set of allowedValues.
