The subset of JSON Schema gm-lib actually enforces.
Protocols let a game publish a schema so agents can discover what a payload must contain. Publishing is easy; enforcing is not, and gm-lib carries no JSON Schema engine. Rather than pretend, this namespace implements a small, flat subset and is explicit about the boundary:
type object, string, number, integer, boolean, array
required list of property names that must be present
additionalProperties false rejects anything not named in properties
properties one level deep, primitive type only
Anything else in a schema is IGNORED, not rejected. A game may publish a richer schema than this — nested objects, enums, patterns, ranges — and it will still be served to agents verbatim through introspection. It simply will not be checked here, and a game that needs those rules enforced must check them itself. Silently ignoring is the honest choice: rejecting a schema we merely cannot check would stop games describing themselves fully, and pretending to validate would be worse than both.
Returns nil when valid, otherwise ONE issue map shaped like the protocol validators' vocabulary — {:field :issue :expected :received} — so callers can fold it into an existing error envelope without translation.
The subset of JSON Schema gm-lib actually enforces.
Protocols let a game publish a schema so agents can discover what a payload
must contain. Publishing is easy; enforcing is not, and gm-lib carries no
JSON Schema engine. Rather than pretend, this namespace implements a small,
flat subset and is explicit about the boundary:
type object, string, number, integer, boolean, array
required list of property names that must be present
additionalProperties false rejects anything not named in properties
properties one level deep, primitive `type` only
Anything else in a schema is IGNORED, not rejected. A game may publish a
richer schema than this — nested objects, enums, patterns, ranges — and it
will still be served to agents verbatim through introspection. It simply
will not be checked here, and a game that needs those rules enforced must
check them itself. Silently ignoring is the honest choice: rejecting a
schema we merely cannot check would stop games describing themselves fully,
and pretending to validate would be worse than both.
Returns nil when valid, otherwise ONE issue map shaped like the protocol
validators' vocabulary — {:field :issue :expected :received} — so callers
can fold it into an existing error envelope without translation.(describe-support)One line a protocol can surface in introspection so an agent knows what is enforced rather than inferring it from a schema that looks complete.
One line a protocol can surface in introspection so an agent knows what is enforced rather than inferring it from a schema that looks complete.
Schema keywords this namespace enforces. Everything else is ignored — see the namespace docstring. Exposed so a protocol can warn a game at registration time about keywords that will not be checked, rather than leaving them to discover it from a request that wrongly succeeded.
Schema keywords this namespace enforces. Everything else is ignored — see the namespace docstring. Exposed so a protocol can warn a game at registration time about keywords that will not be checked, rather than leaving them to discover it from a request that wrongly succeeded.
(unsupported-keywords schema)Schema keywords present in schema that validate will ignore. Shallow:
the top level plus one level of properties, matching what is enforced.
Schema keywords present in `schema` that `validate` will ignore. Shallow: the top level plus one level of `properties`, matching what is enforced.
(validate schema value)(validate schema value field)Check value against the supported subset of schema.
field is the dotted path reported in the issue, so a caller can say which
part of its payload failed. Returns nil when valid, else one issue map.
Check `value` against the supported subset of `schema`. `field` is the dotted path reported in the issue, so a caller can say which part of its payload failed. Returns nil when valid, else one issue map.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |