Documentation
¶
Overview ¶
Package jsonschema is a tiny stdlib-only JSON-schema validator scoped to the keyword subset that the Clockify MCP server's Tier 1 + Tier 2 tool input schemas actually use. It is intentionally narrow:
Supported keywords:
- type: object, string, integer, number, boolean, array
- required (array of strings on objects)
- additionalProperties: false (true is a no-op)
- properties (recursive)
- items (array element schema)
- minimum / maximum (integer and number)
- minLength / maxLength (string)
- pattern (regexp; anchored via ^...$ if not already)
- format: date / date-time (lenient time.Parse)
- enum (array of any; exact JSON-equal match)
Not supported (deliberately): $ref, $defs, allOf/anyOf/oneOf, not, conditionals (if/then/else), dependentSchemas, const, exclusiveMinimum/exclusiveMaximum, multipleOf, propertyNames, patternProperties. None of those keywords appear in the Tier 1 or Tier 2 fleet and adding them would pull complexity with no caller.
Values are validated against the JSON-shaped tree the caller passes in, which in the server is always a map[string]any produced by json.Unmarshal. Integer-vs-number distinction follows Go's native type system: json.Unmarshal decodes every numeric literal as float64, so `type: integer` accepts any float64 whose fractional part is zero.
The validator returns *ValidationError on failure. The caller is expected to wrap that inside a protocol-specific error type (e.g. mcp.InvalidParamsError) and emit the wire response.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ValidationError ¶
ValidationError reports a single validation failure with its JSON Pointer path (RFC 6901). Pointer is empty ("") when the root value itself is the offender.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string