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 ¶
var ErrInvalidSchema = types.ErrInvalidSchema
ErrInvalidSchema indicates that a schema document itself is invalid.
Functions ¶
This section is empty.
Types ¶
type Schema ¶
Schema is a JSON schema.
func NewFromType ¶
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. |