# `Urchin.Schema`
[🔗](https://github.com/urth-inc/urchin/blob/v0.4.0/lib/urchin/schema.ex#L1)

Minimal structural validation of tool arguments against a JSON Schema.

This is a deliberately small subset of JSON Schema, sufficient to catch the common
argument mistakes the DSL's `input_schema` describes, without pulling in a full
validation dependency. It validates `type` (object, array, string, number, integer,
boolean, null, and union types such as `["string", "null"]`), object `properties`,
`required` and `additionalProperties: false`, array `items`, and `enum`. Other keywords
(`minLength`, `pattern`, `format`, ...) are ignored rather than enforced.

Schema keywords may be keyed by string or atom (so `%{"type" => "object"}` and
`%{type: "object"}` both validate); the values being validated come from JSON and are
expected to be string-keyed. For full JSON Schema validation, validate in your handler
with a dedicated library (e.g. `:ex_json_schema`).

# `validate`

```elixir
@spec validate(map() | nil, term()) :: :ok | {:error, String.t()}
```

Validates `value` against `schema`.

Returns `:ok`, or `{:error, message}` describing the first violation. A `nil` schema
(or one without a recognized `type`) accepts any value.

---

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