Help us shape the future of Go! Take the 2026 Go Developer Survey

jsonschema

package
v0.19.12 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 15 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 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 (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