schema

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package schema holds services that allows to validate JSON string against a schema.

Package contains two types of JSON schema validators:

raw - which accepts JSON schema string, reference - which accepts reference to JSON schema,

JSONSchemaRawXGValidator has ability to validate JSON schema string written with draft v4 v6 or v7.
JSONSchemaReferenceXGValidator has ability to validate JSON schema passed as URL or OS path written with draft v4 v6 or v7.

By default, gojsonschema will try to detect the draft of a schema by using the $schema keyword and parse it in a strict draft-04, draft-06 or draft-07 mode. If $schema is missing, or the draft version is not explicitely set, a hybrid mode is used which merges together functionality of all drafts into one mode.

JSONSchemaRawQIValidator has ability to validate JSON schema string written with draft 7 & 2019-09

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONSchemaRawQIValidator added in v1.2.0

type JSONSchemaRawQIValidator struct{}

JSONSchemaRawQIValidator is entity that has ability to validate data against JSON schema passed as string qri-io/jsonschema is used under the hood

func (JSONSchemaRawQIValidator) Validate added in v1.2.0

func (j JSONSchemaRawQIValidator) Validate(document, jsonSchema string) error

Validate validates document against json schema. according to library documentation it covers https://json-schema.org drafts 7 & 2019-09

type JSONSchemaRawXGValidator added in v1.2.0

type JSONSchemaRawXGValidator struct{}

JSONSchemaRawXGValidator is entity that has ability to validate data against JSON schema passed as string. xeipuuv/gojsonschema is used under the hood

func NewJSONSchemaRawXGValidator added in v1.2.0

func NewJSONSchemaRawXGValidator() JSONSchemaRawXGValidator

NewJSONSchemaRawXGValidator creates new JSONSchemaRawXGValidator

func (JSONSchemaRawXGValidator) Validate added in v1.2.0

func (j JSONSchemaRawXGValidator) Validate(document, jsonSchema string) error

Validate validates document against jsonSchema. according to xeipuuv/gojsonschema library it covers JSON Schema, draft v4 v6 & v7

type JSONSchemaReferenceXGValidator added in v1.2.0

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

JSONSchemaReferenceXGValidator is entity that has ability to validate data against JSON schema passed as reference. xeipuuv/gojsonschema is used under the hood.

func NewDefaultJSONSchemaReferenceXGValidator added in v1.2.0

func NewDefaultJSONSchemaReferenceXGValidator(schemasDir string) JSONSchemaReferenceXGValidator

NewDefaultJSONSchemaReferenceXGValidator creates new JSONSchemaReferenceXGValidator with fixed services

func NewJSONSchemaReferenceXGValidator added in v1.2.0

func NewJSONSchemaReferenceXGValidator(schemasDir string, fileValidator v.Validator, urlValidator v.Validator) JSONSchemaReferenceXGValidator

NewJSONSchemaReferenceXGValidator creates new JSONSchemaReferenceXGValidator with provided services

func (JSONSchemaReferenceXGValidator) Validate added in v1.2.0

func (jsv JSONSchemaReferenceXGValidator) Validate(document, schemaPath string) error

Validate validates document against JSON schema located in schemaPath. schemaPath may be URL or relative/full path to json schema on user OS according to xeipuuv/gojsonschema library it covers JSON Schema, draft v4 v6 & v7

Jump to

Keyboard shortcuts

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