ArgumentMatcher
The values that define how to validate a tool-call argument.
Declaration
enum ArgumentMatcherMentioned in
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:
let matchers: [ArgumentMatcher] = [
.exact(argumentName: "city", value: "San Francisco"),
.keyOnly(argumentName: "units"),
.naturalLanguage(argumentName: "prompt", criteria: "A weather-related question")
]Validation Strategy | Rules |
|---|---|
Value must equal the expected value exactly. Use for identifiers, enum values, and precise inputs. | |
Argument must be present with any value. Use when you care that the model provides the parameter but any value is acceptable. | |
Value must be one of the allowed options. Use for ambiguous prompts with multiple valid interpretations. | |
Numeric value must fall within bounds (inclusive). Use for quantities where a range is acceptable. | |
String must match a regular expression. Use for structured formats: emails, dates, IDs. | |
String must contain a substring. Use when the argument references a concept but phrasing varies. | |
String must start with a prefix. Use for paths, URLs, or namespaced values. | |
String must end with a suffix. Use for file extensions or domain-specific endings. | |
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
Set and range matching
ArgumentMatcher.oneOf(argumentName:allowedValues:)ArgumentMatcher.range(argumentName:minimum:maximum:)
String matching
ArgumentMatcher.pattern(argumentName:regex:)ArgumentMatcher.contains(argumentName:substring:)ArgumentMatcher.hasPrefix(argumentName:prefix:)ArgumentMatcher.hasSuffix(argumentName:suffix:)