<!--
{
  "availability" : [
    "Xcode: 27.0.0 -",
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Evaluations",
  "identifier" : "/documentation/Evaluations/ArgumentMatcher",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "Evaluations"
    ],
    "preciseIdentifier" : "s:11Evaluations15ArgumentMatcherO"
  },
  "title" : "ArgumentMatcher"
}
-->

# ArgumentMatcher

The values that define how to validate a tool-call argument.

```
enum ArgumentMatcher
```

## Overview

Use argument matchers to specify validation rules for tool-call arguments. You can require exact values, verify key presence, check ranges, match patterns, or use a language model for semantic matching.

For example:

```swift
let matchers: [ArgumentMatcher] = [
    .exact(argumentName: "city", value: "San Francisco"),
    .keyOnly(argumentName: "units"),
    .naturalLanguage(argumentName: "prompt", criteria: "A weather-related question")
]
```

|Validation Strategy                                                                                              |Rules                                                                                                                                                                                                                         |
|-----------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|``doc://com.apple.evaluations/documentation/Evaluations/ArgumentMatcher/exact(argumentName:value:)``             |Value must equal the expected value exactly. Use for identifiers, enum values, and precise inputs.                                                                                                                            |
|``doc://com.apple.evaluations/documentation/Evaluations/ArgumentMatcher/keyOnly(argumentName:)``                 |Argument must be present with any value. Use when you care that the model provides the parameter but any value is acceptable.                                                                                                 |
|``doc://com.apple.evaluations/documentation/Evaluations/ArgumentMatcher/oneOf(argumentName:allowedValues:)``     |Value must be one of the allowed options. Use for ambiguous prompts with multiple valid interpretations.                                                                                                                      |
|``doc://com.apple.evaluations/documentation/Evaluations/ArgumentMatcher/range(argumentName:minimum:maximum:)``   |Numeric value must fall within bounds (inclusive). Use for quantities where a range is acceptable.                                                                                                                            |
|``doc://com.apple.evaluations/documentation/Evaluations/ArgumentMatcher/pattern(argumentName:regex:)``           |String must match a regular expression. Use for structured formats: emails, dates, IDs.                                                                                                                                       |
|``doc://com.apple.evaluations/documentation/Evaluations/ArgumentMatcher/contains(argumentName:substring:)``      |String must contain a substring. Use when the argument references a concept but phrasing varies.                                                                                                                              |
|``doc://com.apple.evaluations/documentation/Evaluations/ArgumentMatcher/hasPrefix(argumentName:prefix:)``        |String must start with a prefix. Use for paths, URLs, or namespaced values.                                                                                                                                                   |
|``doc://com.apple.evaluations/documentation/Evaluations/ArgumentMatcher/hasSuffix(argumentName:suffix:)``        |String must end with a suffix. Use for file extensions or domain-specific endings.                                                                                                                                            |
|``doc://com.apple.evaluations/documentation/Evaluations/ArgumentMatcher/naturalLanguage(argumentName:criteria:)``|A language model judges whether the value satisfies the criteria. Use when correctness is subjective or hard to express with string operations, for example, validating that a query argument is “a weather-related question”.|

## Topics

### Exact matching

[`ArgumentMatcher.exact(argumentName:value:)`](/documentation/Evaluations/ArgumentMatcher/exact(argumentName:value:))

A value that indicates that the argument must be present with this exact key and value.

[`ArgumentMatcher.keyOnly(argumentName:)`](/documentation/Evaluations/ArgumentMatcher/keyOnly(argumentName:))

A value that indicates that the argument must be present with this key and no specific value.

### Set and range matching

[`ArgumentMatcher.oneOf(argumentName:allowedValues:)`](/documentation/Evaluations/ArgumentMatcher/oneOf(argumentName:allowedValues:))

A value that indicates the argument must be present with a value that matches one of the allowed values.

[`ArgumentMatcher.range(argumentName:minimum:maximum:)`](/documentation/Evaluations/ArgumentMatcher/range(argumentName:minimum:maximum:))

A value that indicates that the argument must be present and its numeric value must be within the specified range.

### String matching

[`ArgumentMatcher.pattern(argumentName:regex:)`](/documentation/Evaluations/ArgumentMatcher/pattern(argumentName:regex:))

A value that indicates that the argument must be present and its string value must match the specified regex pattern.

[`ArgumentMatcher.contains(argumentName:substring:)`](/documentation/Evaluations/ArgumentMatcher/contains(argumentName:substring:))

A value that indicates that the argument must be present and its string value must contain the specified substring.

[`ArgumentMatcher.hasPrefix(argumentName:prefix:)`](/documentation/Evaluations/ArgumentMatcher/hasPrefix(argumentName:prefix:))

A value that indicates that the argument must be present and its string value must start with the specified prefix.

[`ArgumentMatcher.hasSuffix(argumentName:suffix:)`](/documentation/Evaluations/ArgumentMatcher/hasSuffix(argumentName:suffix:))

A value that indicates that the argument must be present and its string value must end with the specified suffix.

### Semantic matching

[`ArgumentMatcher.naturalLanguage(argumentName:criteria:)`](/documentation/Evaluations/ArgumentMatcher/naturalLanguage(argumentName:criteria:))

A value that indicates that the argument must be present and semantically match the given criteria.

### Supporting types

[`ArgumentValue`](/documentation/Evaluations/ArgumentValue)

A primitive, generable value type for argument specifications.

[`StructuredValue`](/documentation/Evaluations/StructuredValue)

A type-safe representation of JSON values.

## Relationships

### Conforms To

[`InstructionsRepresentable`](/documentation/FoundationModels/InstructionsRepresentable)

[`Generable`](/documentation/FoundationModels/Generable)

[`Encodable`](/documentation/Swift/Encodable)

[`ConvertibleFromGeneratedContent`](/documentation/FoundationModels/ConvertibleFromGeneratedContent)

[`Sendable`](/documentation/Swift/Sendable)

[`Decodable`](/documentation/Swift/Decodable)

[`Escapable`](/documentation/Swift/Escapable)

[`PromptRepresentable`](/documentation/FoundationModels/PromptRepresentable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`ConvertibleToGeneratedContent`](/documentation/FoundationModels/ConvertibleToGeneratedContent)

[`Copyable`](/documentation/Swift/Copyable)

---

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)