schematest

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package schematest runs independent JSON Schema contract checks in integration tests. Its pinned JavaScript dependencies are installed only in a test temp dir.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch struct {
	// Schema is the complete schema, including any referenced definitions.
	Schema any `json:"schema"`
	// Instances are JSON values; validation never coerces or mutates them.
	Instances []any `json:"instances"`
}

Batch pairs an emitted schema with the JSON instances to validate against it.

type Result

type Result struct {
	// Valid indicates that the schema accepted the complete instance.
	Valid bool `json:"valid"`
	// Errors contains independent validator diagnostics, empty on success.
	Errors jsontext.Value `json:"errors"`
}

Result reports acceptance and the validator's original failure diagnostics.

type Validator

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

Validator owns a temporary Ajv installation with native ECMA-262 regexes.

func New

func New(t *testing.T) *Validator

New installs the locked test-only validator. Missing tools and installation failures fail the caller; an enabled contract gate can never silently skip.

func (*Validator) Check

func (v *Validator) Check(t *testing.T, batches []Batch) [][]Result

Check validates each batch in order and preserves one result per instance. Invalid schemas and protocol/tool failures fail the caller independently of ordinary instance rejection.

Jump to

Keyboard shortcuts

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