schema

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package schema provides JSON Schema validation backed by santhosh-tekuri/jsonschema.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

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

Registry holds compiled validators keyed by version/action/payload-kind. payloadKind is "request" or "response".

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty registry.

func (*Registry) Lookup

func (r *Registry) Lookup(version, action, kind string) (*Validator, bool)

Lookup returns the validator for the given key, if registered.

func (*Registry) Register

func (r *Registry) Register(version, action, kind string, fsys fs.FS, file string) error

Register compiles and stores a validator.

type Validator

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

Validator validates raw JSON against a compiled OCPP schema.

func New

func New(fsys fs.FS, name string) (*Validator, error)

New compiles the named schema file from the given filesystem.

func (*Validator) Validate

func (v *Validator) Validate(raw []byte) error

Validate checks raw JSON against the schema.

func (*Validator) ValidateLenient added in v0.1.4

func (v *Validator) ValidateLenient(raw []byte) (out []byte, soft []string, err error)

ValidateLenient validates raw and applies the lenient policy:

  • err != nil means a hard-class violation is present; the caller rejects.
  • err == nil means out is the payload (enum case normalized to canonical values when an enum drifted only by case), and soft lists the soft violation keywords seen. out == raw when no enum rewrite was needed, preserving byte order and numeric formatting.

Jump to

Keyboard shortcuts

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