|
pulsatrix 1.1.0
|
A small JSON Schema validator for tool inputs. More...

Go to the source code of this file.
Classes | |
| struct | pulsatrix::orch::SchemaError |
| One way a value fails a schema. More... | |
Namespaces | |
| namespace | pulsatrix |
| namespace | pulsatrix::orch |
Functions | |
| void | pulsatrix::orch::CheckSchema (const JsonValue &schema) |
Checks that schema uses only the supported keywords, each with a valid value. | |
| std::vector< SchemaError > | pulsatrix::orch::ValidateJson (const JsonValue &schema, const JsonValue &value, std::size_t max_errors=16) |
Checks value against schema. | |
| std::string | pulsatrix::orch::StrictModeProblem (const JsonValue &schema) |
Why schema can't be used with Anthropic's strict tool use, or "" if it can. | |
| bool | pulsatrix::orch::JsonEquals (const JsonValue &a, const JsonValue &b) |
JSON equality, as enum, const and uniqueItems use it: numbers by value (1 equals 1.0), objects regardless of member order. | |
A small JSON Schema validator for tool inputs.
It supports only the keywords that mean the same in JSON Schema draft-7 and 2020-12, so one schema works with the Anthropic API, OpenAI-compatible servers and MCP clients, whichever draft they assume:
type (a name or an array of names), enum, constproperties, required, additionalProperties, minProperties, maxPropertiesitems (one schema for every element), minItems, maxItems, uniqueItemsminLength, maxLength (in Unicode code points)minimum, maximum, exclusiveMinimum, exclusiveMaximum (numbers), multipleOfallOf, anyOf, oneOf, nottitle, description, default, examples, format, $comment, and $schema naming draft-7 or 2020-12Any other keyword is refused when the schema is checked, rather than silently not enforced. That includes $ref, $defs/definitions and dependencies, whose spelling or meaning changed between the drafts, items as an array (2020-12's prefixItems), and pattern, since a regular expression engine that is safe on hostile input is more than this needs.