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

schema

package
v1.11.3 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONSchema

type JSONSchema struct {
	Type                 string                `json:"type,omitempty"`
	Description          string                `json:"description,omitempty"`
	Properties           map[string]JSONSchema `json:"properties,omitempty"`
	Required             []string              `json:"required,omitempty"`
	Enum                 []string              `json:"enum,omitempty"`
	Items                *JSONSchema           `json:"items,omitempty"`
	Default              any                   `json:"default,omitempty"`
	AdditionalProperties any                   `json:"additionalProperties,omitempty"`
}

JSONSchema represents a JSON Schema for tool input.

func FromMap

func FromMap(schemaMap map[string]any) JSONSchema

FromMap converts a permissive map representation into the structured schema model used by the contract types.

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator validates tool input against JSON Schema.

func NewValidator

func NewValidator() *Validator

NewValidator creates a new schema validator.

func (*Validator) RegisterSchema

func (v *Validator) RegisterSchema(toolName string, schema JSONSchema)

RegisterSchema registers a JSON schema for a tool.

func (*Validator) RegisterSchemaFromMap

func (v *Validator) RegisterSchemaFromMap(toolName string, schemaMap map[string]any) error

RegisterSchemaFromMap registers a schema from a map (useful for simple definitions).

func (*Validator) Validate

func (v *Validator) Validate(toolName string, input map[string]any) (map[string]any, error)

Validate validates input against the registered schema for the tool. Returns a normalized input map if validation succeeds.

Jump to

Keyboard shortcuts

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