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

# Validate Within Dir • AI Agent SDK

> validate_within_dir: Validate that a path is contained within an allowed root directory.

# validate\_within\_dir

Function

> This function is defined in the [**workspace**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/workspace.md) module.

Validate that a path is contained within an allowed root directory.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def validate_within_dir(path: Path, allowed_root: Path) -> bool
```

## Parameters

**path** `Path` *required*

Path to validate

**allowed\_root** `Path` *required*

Root directory that must contain the path

### Returns

**Returns** `bool`

True if path is within allowed\_root, False otherwise

## Uses

* `relative_to`
* `path.resolve`
* `allowed_root.resolve`

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/workspace/__init__.py#L153)
>
> `praisonaiagents/workspace/__init__.py` at line 153


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.