> ## 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.

# Guardrail Chain • Rust AI Agent SDK

> GuardrailChain: Chain of guardrails to run in sequence.

# GuardrailChain

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

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

Chain of guardrails to run in sequence.

## Fields

| Name         | Type                                  | Description |
| ------------ | ------------------------------------- | ----------- |
| `guardrails` | `Vec&lt;Box&lt;dyn Guardrail&gt;&gt;` | -           |
| `config`     | `GuardrailConfig`                     | -           |

## Methods

### `new`

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

Create a new guardrail chain

### `add`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn add(mut self, guardrail: impl Guardrail + 'static) -> Self
```

Add a guardrail to the chain

**Parameters:**

| Name        | Type                       |
| ----------- | -------------------------- |
| `guardrail` | `impl Guardrail + 'static` |

### `config`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn config(mut self, config: GuardrailConfig) -> Self
```

Set config

**Parameters:**

| Name     | Type              |
| -------- | ----------------- |
| `config` | `GuardrailConfig` |

### `validate`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn validate(&self, output: &str) -> GuardrailResult
```

Validate output through all guardrails

**Parameters:**

| Name     | Type   |
| -------- | ------ |
| `output` | `&str` |

### `len`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn len(&self) -> usize
```

Get guardrail count

### `is_empty`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn is_empty(&self) -> bool
```

Check if empty

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/guardrails/mod.rs#L479">
  `praisonai/src/guardrails/mod.rs` at line 479
</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>
