> ## 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](../type-references/Attachment) type.

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

## Examples

<CodeGroup>
  ```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"
  ```
</CodeGroup>

## Arguments

<ResponseField name="data" type="dict[str, Any] | list[dict[str, Any]]" required>
  The data to validate. Can be a single data object or an array of data objects.
</ResponseField>

<ResponseField name="schema" type="dict[str, Any]" required>
  JSON schema object defining validation rules
</ResponseField>

## Returns: `None`

Returns nothing if validation passes, raises ValidationError if it fails

## Raises

### ValidationError

If validation fails
