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

# Length Guardrail • Rust AI Agent SDK

> LengthGuardrail: Content length guardrail.

# LengthGuardrail

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

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

Content length guardrail.

## Fields

| Name         | Type                  | Description    |
| ------------ | --------------------- | -------------- |
| `min_length` | `Option&lt;usize&gt;` | Minimum length |
| `max_length` | `Option&lt;usize&gt;` | Maximum length |

## Methods

### `new`

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

Create a new length guardrail

### `min`

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

Set minimum length

**Parameters:**

| Name     | Type    |
| -------- | ------- |
| `length` | `usize` |

### `max`

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

Set maximum length

**Parameters:**

| Name     | Type    |
| -------- | ------- |
| `length` | `usize` |

## Source

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