Documentation
¶
Overview ¶
Package jsonschema adapts immutable contract-catalog JSON assets to the JSON Schema validator without exposing the JSON Schema library to domain code.
Index ¶
Constants ¶
const MaxInputBytes = 8 << 20
MaxInputBytes is the maximum size of one JSON instance accepted by Validate. The finite 8 MiB limit bounds decoding and schema-validation memory use.
Variables ¶
This section is empty.
Functions ¶
func ReadinessAuthority ¶
ReadinessAuthority reports whether schemaID is an authoritative readiness contract. Only the provider and platform v1 evidence schemas are authority.
Types ¶
type Diagnostic ¶
Diagnostic is a redacted, typed failure produced at the JSON Schema adapter boundary. Path is a JSON Pointer-like location. It deliberately retains no implementation cause, so validation input cannot escape through error chains.
func (*Diagnostic) DocumentViolation ¶
func (diagnostic *Diagnostic) DocumentViolation() bool
DocumentViolation reports whether this diagnostic was caused by provider document bytes rather than validator configuration or runtime state.
func (*Diagnostic) Error ¶
func (diagnostic *Diagnostic) Error() string
Error implements error without rendering untrusted input or the underlying error text, which may be more detailed than this boundary should expose.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator is an immutable, compiled set of catalog JSON schemas and copied JSON examples. It does not retain caller-provided validation bytes.
func New ¶
New loads, verifies, and compiles every schema in catalog. Compilation is fail-closed: schemas must be draft 2020-12 resources whose JSON $id exactly matches the catalog AssetID, references must be local fragments, and the compiler's loader always denies external resources.
func (*Validator) Validate ¶
func (validator *Validator) Validate(ctx context.Context, schemaID ports.AssetID, raw []byte) (result error)
Validate strictly decodes raw as exactly one JSON value before applying the compiled schema identified by schemaID.
func (*Validator) ValidatePair ¶
func (validator *Validator) ValidatePair(ctx context.Context, schemaID, exampleID ports.AssetID) error
ValidatePair validates the one catalog example paired with schemaID by the embedded file catalog. Both IDs must name the compiled schema and copied JSON example captured when the validator was constructed.