Documentation
¶
Overview ¶
Package jsonschema provides lossless JSON Schema Draft 7 values used by OpenRPC. It supports both object and boolean schemas without reflection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrValidationPolicy reports invalid compilation or diagnostic bounds. ErrValidationPolicy = errors.New("jsonschema: invalid validation policy") // ErrSchemaCompile reports a schema that is not valid Draft 7 or contains // a reference absent from the explicit resource set. ErrSchemaCompile = errors.New("jsonschema: Draft 7 compilation failed") // ErrInvalidInstance reports an invalid zero instance value. ErrInvalidInstance = errors.New("jsonschema: invalid instance") // ErrValidationResourceLimit reports that bounded validation could not // complete without exceeding its configured work limit. ErrValidationResourceLimit = errors.New("jsonschema: validation resource limit exceeded") )
var ErrInvalidSchema = errors.New("jsonschema: schema must be an object or boolean")
ErrInvalidSchema reports a valid JSON value that is neither an object nor a boolean and therefore cannot be a Draft 7 schema.
Functions ¶
This section is empty.
Types ¶
type Report ¶
type Report struct {
// contains filtered or unexported fields
}
Report is one immutable bounded validation result.
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is an immutable object or boolean JSON Schema value.
func Parse ¶
Parse validates and preserves an object or boolean JSON Schema value under policy. Keyword and reference semantics are validated separately.
func (Schema) Boolean ¶
Boolean returns the schema value and true for a boolean schema. The second result is false for an object schema.
func (Schema) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
type ValidationOptions ¶
type ValidationOptions struct {
BaseURI string
Resources map[string]Schema
MaxResources int
MaxSchemaBytes int
MaxIssues int
RegexpTimeout time.Duration
}
ValidationOptions configures Draft 7 compilation and bounded reporting. Resources are the only external schemas available during compilation; no filesystem or network loader is installed.
func DefaultValidationOptions ¶
func DefaultValidationOptions() ValidationOptions
DefaultValidationOptions returns strict Draft 7 compilation with finite diagnostic output and no external resources.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator is an immutable compiled Draft 7 schema safe for concurrent use.
func Compile ¶
func Compile(schema Schema, options ValidationOptions) (Validator, error)
Compile compiles one Draft 7 schema using only explicitly supplied resources. It never performs network or filesystem access.