jsonschema

package
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(schema Schema, value any) (any, error)

Validate clones value, applies the same primitive coercions used by upstream tool validation, and validates the converted value against schema.

func ValidateToolArguments

func ValidateToolArguments(toolName string, schema Schema, arguments any) (any, error)

ValidateToolArguments formats failures like the upstream TypeBox adapter so loop-generated error tool results remain trace-compatible.

func ValidateToolArgumentsJSON

func ValidateToolArgumentsJSON(toolName string, schema Schema, argumentsJSON []byte) (any, error)

ValidateToolArgumentsJSON preserves the provider's argument member order in the diagnostic's pretty-printed input. Callers with a retained raw tool call should prefer this form over re-encoding its arguments map.

Types

type Schema

type Schema json.RawMessage

Schema contains a JSON Schema value without imposing a Go-side schema model. The zero value is the valid unconstrained schema {}.

func FromStruct

func FromStruct[T any]() (Schema, error)

FromStruct derives a plain, inline JSON Schema from T. Fields are required unless their json tag contains omitempty/omitzero or their jsonschema tag contains optional. Supported jsonschema directives are description, enum, required, and optional.

func StringEnum

func StringEnum(values ...string) Schema

StringEnum builds the enum form accepted by Google and the other providers: {"type":"string","enum":[...]}.

func (Schema) MarshalJSON

func (s Schema) MarshalJSON() ([]byte, error)

MarshalJSON returns the stored schema bytes unchanged.

func (*Schema) UnmarshalJSON

func (s *Schema) UnmarshalJSON(data []byte) error

UnmarshalJSON retains the input representation so schemas received from JS extensions or MCP can pass through without a Go-side rewrite.

type ValidationErrors

type ValidationErrors []ValidationIssue

func (ValidationErrors) Error

func (errors ValidationErrors) Error() string

type ValidationIssue

type ValidationIssue struct {
	Path    string
	Message string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL