schema

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT, BSD-3-Clause Imports: 8 Imported by: 1

Documentation

Overview

Package schema validates JSON documents against JSON schemas, supporting draft 2020-12.

This package is the entry point for common use: parsing a schema with New or deriving one from a Go type with NewFromType, and validating instances with [Schema.Validate]. The subpackages hold the core representation (types), the draft 2020-12 vocabulary (draft202012), format validators (format), and schema construction (builder).

The implementation derives from the Go team's jsonschema prototype; see the LICENSE file in this directory.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSchema = types.ErrInvalidSchema

ErrInvalidSchema indicates that a schema document itself is invalid.

Functions

This section is empty.

Types

type Schema

type Schema = types.Schema

Schema is a JSON schema.

func New

func New(data []byte) (*Schema, error)

New parses a JSON schema.

func NewFromType

func NewFromType[T any]() (*Schema, error)

NewFromType derives a JSON schema from a Go type.

type ValidateError

type ValidateError = types.ValidateError

ValidateError is the error returned by [Schema.Validate] when an instance fails validation. It matches motmedelErrors.ErrValidationError with errors.Is.

type ValidationError

type ValidationError = types.ValidationError

ValidationError is a single validation failure within a ValidateError.

Directories

Path Synopsis
Package builder defines a Builder type that may be used to build a [jsonschema.Schema] step by step.
Package builder defines a Builder type that may be used to build a [jsonschema.Schema] step by step.
Package draft202012 defines the keywords used by JSON schema version 2020-12.
Package draft202012 defines the keywords used by JSON schema version 2020-12.
Package format defines format checkers for the format keyword.
Package format defines format checkers for the format keyword.
internal
argtype
Package argtype defines a few helpers for schema.ArgType.
Package argtype defines a few helpers for schema.ArgType.
cmd/keywordgen command
keywordgen generates repetitive code for JSON schema keywords.
keywordgen generates repetitive code for JSON schema keywords.
cmd/testgen command
testgen downloads the current testsuite from json-schema-org and updates the tests in the tree.
testgen downloads the current testsuite from json-schema-org and updates the tests in the tree.
cmd/validatorgen command
validatorgen generates validator functions for different schema argument types.
validatorgen generates validator functions for different schema argument types.
schemacache
Package schemacache is a simple in-process cache for schemas that have been parsed.
Package schemacache is a simple in-process cache for schemas that have been parsed.
validator
Package validator contains functions to handle different schema arguments.
Package validator contains functions to handle different schema arguments.
Package jsonpointer implements JSON pointers for the jsonschema package.
Package jsonpointer implements JSON pointers for the jsonschema package.
Package notes defines a type that holds information passed between keywords during schema validation.
Package notes defines a type that holds information passed between keywords during schema validation.

Jump to

Keyboard shortcuts

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