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
{: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()
)
Summary
Functions
Returns the maximum schema complexity accepted by this module.
Returns the complexity measure for a schema value.
Returns the schema dialect supported by this module.
Compares two values for equality under this module’s rules.
Parses a schema document for the requested dialect.
Validates a tagged JSON instance against a schema.
Types
@type t() :: %AgentBlueprintProtocol.Schema{ complexity: non_neg_integer(), dialect: binary(), pointers: pointers(), root: AgentBlueprintProtocol.Json.value() }
The public data type for AgentBlueprintProtocol.Schema.
Functions
@spec ceiling() :: pos_integer()
Returns the maximum schema complexity accepted by this module.
Example
AgentBlueprintProtocol.Schema.ceiling()
@spec complexity(AgentBlueprintProtocol.Json.value()) :: non_neg_integer()
Returns the complexity measure for a schema value.
Example
AgentBlueprintProtocol.Schema.complexity({:object, [{"ready", {:boolean, true}}]})
@spec dialect() :: binary()
Returns the schema dialect supported by this module.
Example
AgentBlueprintProtocol.Schema.dialect()
@spec equal?(AgentBlueprintProtocol.Json.value(), AgentBlueprintProtocol.Json.value()) :: boolean()
Compares two values for equality under this module’s rules.
Example
AgentBlueprintProtocol.Schema.equal?({:integer, 1}, {:float, 1.0})
@spec parse(AgentBlueprintProtocol.Json.value(), binary()) :: {:ok, t()} | {:error, AgentBlueprintProtocol.Error.t()}
Parses a schema document for the requested dialect.
Example
{:ok, schema_value} = AgentBlueprintProtocol.Json.decode(~s({"type":"string"}))
match?(
{:ok, %AgentBlueprintProtocol.Schema{}},
AgentBlueprintProtocol.Schema.parse(
schema_value,
AgentBlueprintProtocol.Schema.dialect()
)
)
@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
{: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()
)