> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Pattern Guardrail • Rust AI Agent SDK

> PatternGuardrail: Regex pattern guardrail.

# PatternGuardrail

> Defined in the [**guardrails**](../modules/guardrails) module.

<Badge color="orange">Rust AI Agent SDK</Badge>

Regex pattern guardrail.

## Fields

| Name             | Type                   | Description                                       |
| ---------------- | ---------------------- | ------------------------------------------------- |
| `must_match`     | `Option&lt;String&gt;` | Pattern to match (must match for success)         |
| `must_not_match` | `Option&lt;String&gt;` | Pattern to not match (must not match for success) |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new() -> Self
```

Create a new pattern guardrail

### `must_match`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn must_match(mut self, pattern: impl Into<String>) -> Self
```

Set must match pattern

**Parameters:**

| Name      | Type                      |
| --------- | ------------------------- |
| `pattern` | `impl Into&lt;String&gt;` |

### `must_not_match`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn must_not_match(mut self, pattern: impl Into<String>) -> Self
```

Set must not match pattern

**Parameters:**

| Name      | Type                      |
| --------- | ------------------------- |
| `pattern` | `impl Into&lt;String&gt;` |

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/guardrails/mod.rs#L404">
  `praisonai/src/guardrails/mod.rs` at line 404
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Guardrails" icon="shield" href="/docs/rust/guardrails" />

  <Card title="Rust Approval" icon="check" href="/docs/rust/approval" />

  <Card title="Rust Security" icon="lock" href="/docs/rust/security" />
</CardGroup>
