Documentation
¶
Overview ¶
Package jsonschema is a tiny stdlib-only JSON-schema validator scoped to the keyword subset that the Clockify MCP server's one-user tool input schemas actually use. It is intentionally narrow:
Supported keywords:
- type: object, string, integer, number, boolean, array, null
- required (array of strings on objects)
- additionalProperties: false (true is a no-op)
- properties (recursive)
- items (array element schema)
- minItems (array)
- minimum / maximum (integer and number)
- minLength / maxLength (string)
- pattern (regexp; anchored via ^...$ if not already)
- format: date / date-time (lenient time.Parse) / email (minimal shape)
- enum (array of any; exact JSON-equal match)
- anyOf (array of schemas; at least one must validate)
Not supported (deliberately): $ref, $defs, allOf/oneOf, not, conditionals (if/then/else), dependentSchemas, const, exclusiveMinimum/exclusiveMaximum, multipleOf, propertyNames, patternProperties. None of those keywords appear in the current tool surface 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