validate

package module
v0.0.0-...-a7abcff Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Provides JSON Schema validation API.

Uses the embedded blueprint.SchemaJSON to validate against JSON or YAML documents.

Index

Constants

This section is empty.

Variables

View Source
var ErrCannotCompileSchema = errors.New("cannot compile schema")

ErrCannotCompileSchema is returned when the schema cannot be compiled.

Functions

This section is empty.

Types

type Schema

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

func CompileSchema

func CompileSchema() (*Schema, error)

CompileSchema compiles the JSON schema. Uses the embedded schema available as blueprint.SchemaJSON.

func (*Schema) ReadAndValidateJSON

func (s *Schema) ReadAndValidateJSON(reader io.Reader) (bool, string, error)

ReadAndValidateJSON reads JSON from the reader and calls ValidateMap.

func (*Schema) ReadAndValidateYAML

func (s *Schema) ReadAndValidateYAML(reader io.Reader) (bool, string, error)

ReadAndValidateYAML reads YAML from the reader and calls ValidateMap.

func (*Schema) ValidateJSON

func (s *Schema) ValidateJSON(data []byte) (bool, string, error)

ValidateJSON unmarshals JSON and calls ValidateMap.

func (*Schema) ValidateMap

func (s *Schema) ValidateMap(data map[string]any) (bool, string)

ValidateMap validates the map against the schema. Returns true if the data is valid, otherwise false and a string with details.

func (*Schema) ValidateYAML

func (s *Schema) ValidateYAML(data []byte) (bool, string, error)

ValidateYAML unmarshals YAML and calls ValidateMap.

Jump to

Keyboard shortcuts

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