# `ExMCP.Content.SchemaValidator`
[🔗](https://github.com/azmaveth/ex_mcp/blob/v1.0.0/lib/ex_mcp/content/schema_validator.ex#L1)

Schema validation for MCP content.

> #### Experimental {: .warning}
>
> Helper utilities outside the core Handler/DSL path. Prefer tool
> `output_schema` on `ExMCP.Server.DSL` for structured tool results.

Field/size/MIME helpers are implemented. `validate_schema/3` uses
`ExJsonSchema` behind `ExMCP.Content.SchemaPolicy`, which rejects remote
references and bounds schema complexity and execution time.

# `validation_error`

```elixir
@type validation_error() :: %{
  rule: atom(),
  message: String.t(),
  field: String.t() | nil,
  value: any(),
  severity: :error | :warning | :info
}
```

# `validation_result`

```elixir
@type validation_result() :: :ok | {:error, [validation_error()]}
```

# `compile_schema`

```elixir
@spec compile_schema(
  map() | boolean(),
  keyword()
) :: ExMCP.Content.SchemaPolicy.compile_result()
```

Preflights and resolves a JSON Schema under ExMCP's resource policy.

# `validate_format`

```elixir
@spec validate_format(ExMCP.Content.Protocol.content()) :: validation_result()
```

Validates content format and structure.

# `validate_max_size`

```elixir
@spec validate_max_size(ExMCP.Content.Protocol.content(), pos_integer()) ::
  validation_result()
```

Validates content size against maximum limits.

# `validate_mime_types`

```elixir
@spec validate_mime_types(ExMCP.Content.Protocol.content(), [String.t()]) ::
  validation_result()
```

Validates MIME types against allowed types.

# `validate_required_fields`

```elixir
@spec validate_required_fields(ExMCP.Content.Protocol.content()) ::
  validation_result()
```

Validates that required fields are present and non-empty.

# `validate_schema`

```elixir
@spec validate_schema(
  ExMCP.Content.Protocol.content() | map(),
  map() | boolean(),
  keyword()
) ::
  validation_result()
```

Validates content against a JSON Schema using ExJsonSchema.

Content maps are converted to JSON-compatible string-keyed maps (atoms
become strings) before validation.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
