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

# validate_data_using_schema

Validates data against a JSON schema using the AJV validator.
This function can validate any given data against a given schema. It supports validating custom data types such as the [Attachment](https://intunedhq.com/docs/automation-sdks/intuned-sdk/python/helpers/type-references/Attachment.md) type.

```python theme={null}
def validate_data_using_schema(
    data: dict[str, Any] | list[dict[str, Any]],
    schema: dict[str, Any],
)
```

## Examples

```python Basic Validation theme={null}
from typing import TypedDict
from playwright.async_api import Page
from intuned_browser import validate_data_using_schema
class Params(TypedDict):
    pass
async def automation(page: Page, params: Params, **_kwargs):
    upload_data = {
        "file": {
            "file_name": "documents/report.pdf",
            "bucket": "my-bucket",
            "region": "us-east-1",
            "key": "documents/report.pdf",
            "endpoint": None,
            "suggested_file_name": "Monthly Report.pdf",
            "file_type": "document"
        },
        "name": "Test File Upload"
    }
    upload_schema = {
        "type": "object",
        "required": ["file", "name"],
        "properties": {
            "file": {"type": "attachment"},
            "name": {"type": "string"}
        }
    }
    validate_data_using_schema(upload_data, upload_schema)
    # Validation passes with Attachment type
    print("Validation passed")
    return "Validation passed"
```

```python Invalid Data Validation theme={null}
from typing import TypedDict
from playwright.async_api import Page
from intuned_browser import validate_data_using_schema
class Params(TypedDict):
    pass
async def automation(page: Page, params: Params, **_kwargs):
    user_data = {
        "name": "John Doe",
        "email": "john@example.com",
    }
    user_schema = {
        "type": "object",
        "required": ["name", "email", "age"],
        "properties": {
            "name": {"type": "string", "minLength": 1},
            "email": {"type": "string", "format": "email"},
            "age": {"type": "number", "minimum": 0}
        }
    }
    validate_data_using_schema(user_data, user_schema)  # this will throw
    # Validation fails, throws ValidationError
    print("Never reached")
    return "Never reached"
```

## Arguments

**data** `dict[str, Any] | list[dict[str, Any]]` *required*

The data to validate. Can be a single data object or an array of data objects.

**schema** `dict[str, Any]` *required*

JSON schema object defining validation rules

## Returns: `None`

Returns nothing if validation passes, raises ValidationError if it fails

## Raises

### ValidationError

If validation fails


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