jsonschema

package
v0.104.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateBytes

func ValidateBytes(schemaBytes []byte, data []byte, context *ReferenceContext) error

func ValidateGoStruct

func ValidateGoStruct(schemaBytes []byte, data interface{}, context *ReferenceContext) error

func ValidateSchema

func ValidateSchema(schemaBytes []byte) error

ValidateSchema validates a jsonschema schema definition.

func ValidateSchemaWithLoader

func ValidateSchemaWithLoader(loader gojsonschema.JSONLoader) error

ValidateSchemaWithLoader validates a jsonschema schema definition by using the given loader.

Types

type ReferenceContext

type ReferenceContext struct {
	// LocalTypes is a map of blueprint locally defined types.
	// It is a map of schema name to schema definition
	LocalTypes map[string]lsv1alpha1.JSONSchemaDefinition
	// BlueprintFs is the virtual filesystem that is used to resolve "blueprint" refs
	BlueprintFs vfs.FileSystem
	// ComponentVersion contains the current blueprint's component descriptor.
	ComponentVersion model.ComponentVersion
	// RegistryAccess is an object that can resolve component descriptors.
	RegistryAccess model.RegistryAccess
	// RepositoryContext can be used to overwrite the effective repository context of the component descriptor.
	// If not set, the effective repository context of the ComponentDescriptor will be used.
	RepositoryContext *types.UnstructuredTypedObject
}

ReferenceContext describes the context of the current reference.

type ReferenceResolver

type ReferenceResolver struct {
	*ReferenceContext
}

func NewReferenceResolver

func NewReferenceResolver(refCtx *ReferenceContext) *ReferenceResolver

func (*ReferenceResolver) Resolve

func (rr *ReferenceResolver) Resolve(schemaBytes []byte) (interface{}, error)

Resolve walks through the given json schema and recursively resolves all references which use one of the "local", "blueprint", or "cd" schemes.

type Validator

type Validator struct {
	Context *ReferenceContext
	Schema  *gojsonschema.Schema
}

func NewValidator

func NewValidator(context *ReferenceContext) *Validator

NewValidator returns a new Validator with the given reference context.

func (*Validator) CompileSchema

func (v *Validator) CompileSchema(schemaBytes []byte) error

CompileSchema compiles the given schema and sets it as schema for the validator

func (*Validator) ValidateBytes

func (v *Validator) ValidateBytes(data []byte) error

func (*Validator) ValidateGoStruct

func (v *Validator) ValidateGoStruct(data interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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