---
title: "constrain(_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/attributedtextformattingdefinition/constrain(_:)"
---

# constrain(_:)

Applies all value constraints to a given attribute container.

## Declaration

```swift
func constrain(_ container: inout AttributeContainer)
```

## Discussion

Discussion Modifies the given container by applying all AttributedTextValueConstraints that are part of this definition to the container. Use this function to test your AttributedTextFormattingDefinition, or to ensure your constraints are applied before passing content to API that cannot itself apply the definition.
