# `AgentBlueprintProtocol.Schema`
[🔗](https://github.com/baselabs/agent_blueprint_protocol/blob/v1.1.0/lib/agent_blueprint_protocol/schema.ex#L1)

This module parses bounded schemas and validates tagged JSON instances.

Use it when validating a schema document or an instance against a supported dialect.

This module does not authorize operations.

## Example

```elixir
{:ok, schema_value} = AgentBlueprintProtocol.Json.decode(~s({"type":"string"}))
{:ok, schema} =
  AgentBlueprintProtocol.Schema.parse(
    schema_value,
    AgentBlueprintProtocol.Schema.dialect()
  )
AgentBlueprintProtocol.Schema.validate_instance(
  schema,
  {:string, "ready"},
  AgentBlueprintProtocol.Schema.dialect()
)
```

# `t`
*since 1.0.0* 

```elixir
@type t() :: %AgentBlueprintProtocol.Schema{
  complexity: non_neg_integer(),
  dialect: binary(),
  pointers: pointers(),
  root: AgentBlueprintProtocol.Json.value()
}
```

The public data type for AgentBlueprintProtocol.Schema.

# `ceiling`
*since 1.0.0* 

```elixir
@spec ceiling() :: pos_integer()
```

Returns the maximum schema complexity accepted by this module.

## Example

```elixir
AgentBlueprintProtocol.Schema.ceiling()
```

# `complexity`
*since 1.0.0* 

```elixir
@spec complexity(AgentBlueprintProtocol.Json.value()) :: non_neg_integer()
```

Returns the complexity measure for a schema value.

## Example

```elixir
AgentBlueprintProtocol.Schema.complexity({:object, [{"ready", {:boolean, true}}]})
```

# `dialect`
*since 1.0.0* 

```elixir
@spec dialect() :: binary()
```

Returns the schema dialect supported by this module.

## Example

```elixir
AgentBlueprintProtocol.Schema.dialect()
```

# `equal?`
*since 1.0.0* 

```elixir
@spec equal?(AgentBlueprintProtocol.Json.value(), AgentBlueprintProtocol.Json.value()) ::
  boolean()
```

Compares two values for equality under this module’s rules.

## Example

```elixir
AgentBlueprintProtocol.Schema.equal?({:integer, 1}, {:float, 1.0})
```

# `parse`
*since 1.0.0* 

```elixir
@spec parse(AgentBlueprintProtocol.Json.value(), binary()) ::
  {:ok, t()} | {:error, AgentBlueprintProtocol.Error.t()}
```

Parses a schema document for the requested dialect.

## Example

```elixir
{:ok, schema_value} = AgentBlueprintProtocol.Json.decode(~s({"type":"string"}))

match?(
  {:ok, %AgentBlueprintProtocol.Schema{}},
  AgentBlueprintProtocol.Schema.parse(
    schema_value,
    AgentBlueprintProtocol.Schema.dialect()
  )
)
```

# `validate_instance`
*since 1.0.0* 

```elixir
@spec validate_instance(
  t() | AgentBlueprintProtocol.Json.value(),
  AgentBlueprintProtocol.Json.value(),
  binary()
) :: :ok | {:error, AgentBlueprintProtocol.Error.t()}
```

Validates a tagged JSON instance against a schema.

## Example

```elixir
{:ok, schema_value} = AgentBlueprintProtocol.Json.decode(~s({"type":"string"}))
{:ok, schema} =
  AgentBlueprintProtocol.Schema.parse(
    schema_value,
    AgentBlueprintProtocol.Schema.dialect()
  )

AgentBlueprintProtocol.Schema.validate_instance(
  schema,
  {:string, "ready"},
  AgentBlueprintProtocol.Schema.dialect()
)
```

---

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