Lightweight schema validation for Action input/output.
No external dependencies -- pure pattern matching on keyword list specs.
Field Specs
schema = [
path: [type: :string, required: true, description: "File path"],
timeout: [type: :integer, default: 5000],
format: [type: :string, enum: ["json", "text"], default: "text"]
]Supported types: :string, :integer, :float, :boolean, :atom,
:map, :list, {:list, type}.
Summary
Functions
Convert a schema to a JSON Schema-compatible tool definition.
Validate params against a schema.
Types
@type field_spec() :: keyword()
@type schema() :: [{atom(), field_spec()}]
Functions
Convert a schema to a JSON Schema-compatible tool definition.
Produces the OpenAI/Anthropic function calling format:
%{
"type" => "function",
"function" => %{
"name" => name,
"description" => description,
"parameters" => %{
"type" => "object",
"properties" => %{...},
"required" => [...]
}
}
}
Validate params against a schema.
Returns {:ok, validated_params} with defaults applied,
or {:error, [{field, reason}]} on failure.