lxSchema

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitJsonSchemaLoader

func InitJsonSchemaLoader()

InitJsonSchemaLoader - initiate JSONSchemaLoader globally as Loader

Types

type IJSONSchema

type IJSONSchema interface {
	SetSchemaRootDirectory(dirname string) error
	HasSchema(filename string) bool
	LoadSchema(filename string) (gojsonschema.JSONLoader, error)
	ValidateBind(schema string, req *http.Request, s interface{}) (*JSONValidationResult, error)
	ValidateBindRaw(schema string, data *[]byte, s interface{}) (*JSONValidationResult, error)
}
var Loader IJSONSchema

type JSONSchema

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

func (*JSONSchema) HasSchema

func (js *JSONSchema) HasSchema(filename string) bool

HasSchema - checks, if schema already loaded

func (*JSONSchema) LoadSchema

func (js *JSONSchema) LoadSchema(filename string) (gojsonschema.JSONLoader, error)

LoadSchema - loads a schema and holds it, return schema or error

func (*JSONSchema) SetSchemaRootDirectory

func (js *JSONSchema) SetSchemaRootDirectory(dirname string) error

SetSchemaRootDirectory - sets default root schema directory

func (*JSONSchema) ValidateBind

func (js *JSONSchema) ValidateBind(schema string, req *http.Request, s interface{}) (*JSONValidationResult, error)

ValidateBind - validate given c:echo.Context with schema and binds if success to s:interface{} - if schema not loaded func will perform it

func (*JSONSchema) ValidateBindRaw added in v1.5.15

func (js *JSONSchema) ValidateBindRaw(schema string, data *[]byte, s interface{}) (*JSONValidationResult, error)

ValidateBindRaw - validate given byte array with schema and binds if success to interface{}

type JSONValidationErrors

type JSONValidationErrors struct {
	Field   string                 `json:"field"`
	Message string                 `json:"message"`
	Details map[string]interface{} `json:"details"`
}

type JSONValidationResult

type JSONValidationResult struct {
	Errors []JSONValidationErrors `json:"errors"`
}

Directories

Path Synopsis
Package lxSchemaMocks is a generated GoMock package.
Package lxSchemaMocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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