validator

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONSchemaValidator

type JSONSchemaValidator struct {
	SchemaStorage Storage
	// contains filtered or unexported fields
}

JSONSchemaValidator validator

func NewJSONSchemaValidator

func NewJSONSchemaValidator(opts ...JSONSchemaValidatorOptionFunc) *JSONSchemaValidator

NewJSONSchemaValidator constructor

func (*JSONSchemaValidator) ValidateDocument

func (v *JSONSchemaValidator) ValidateDocument(schemaSource string, documentSource any) error

ValidateDocument based on schema id

type JSONSchemaValidatorOptionFunc added in v1.14.0

type JSONSchemaValidatorOptionFunc func(*JSONSchemaValidator)

JSONSchemaValidatorOptionFunc type

func AddHideErrorListTypeJSONSchemaValidatorOption added in v1.14.0

func AddHideErrorListTypeJSONSchemaValidatorOption(descType ...string) JSONSchemaValidatorOptionFunc

AddHideErrorListTypeJSONSchemaValidatorOption option func

func SetSchemaStorageJSONSchemaValidatorOption added in v1.14.0

func SetSchemaStorageJSONSchemaValidatorOption(s Storage) JSONSchemaValidatorOptionFunc

SetSchemaStorageJSONSchemaValidatorOption option func

type OptionFunc added in v1.14.0

type OptionFunc func(*Validator)

OptionFunc type

func SetJSONSchemaValidator added in v1.14.0

func SetJSONSchemaValidator(jsonSchema *JSONSchemaValidator) OptionFunc

SetJSONSchemaValidator option func

func SetStructValidator added in v1.14.0

func SetStructValidator(structValidator *StructValidator) OptionFunc

SetStructValidator option func

type Storage added in v1.11.15

type Storage interface {
	Get(schemaID string) (string, error)
	Store(schemaID string, schema string) error
}

Storage abstraction

func NewFileLocalStorage added in v1.14.0

func NewFileLocalStorage(schemaLocationDir string) Storage

NewFileLocalStorage read from file

func NewFileSystemStorage added in v1.17.9

func NewFileSystemStorage(fileSystem fs.FS, rootPath string) Storage

NewFileSystemStorage constructor

func NewInMemStorage added in v1.11.15

func NewInMemStorage(schemaLocationDir string) Storage

NewInMemStorage constructor

type StructValidator

type StructValidator struct {
	Validator *validatorengine.Validate
}

StructValidator struct

func NewStructValidator

func NewStructValidator(opts ...StructValidatorOptionFunc) *StructValidator

NewStructValidator using go library https://github.com/go-playground/validator (all struct tags will be here) https://godoc.org/github.com/go-playground/validator (documentation using it) NewStructValidator function

func (*StructValidator) ValidateStruct

func (v *StructValidator) ValidateStruct(data any) error

ValidateStruct function

type StructValidatorOptionFunc added in v1.14.0

type StructValidatorOptionFunc func(*StructValidator)

StructValidatorOptionFunc type

func SetCoreStructValidatorOption added in v1.14.0

func SetCoreStructValidatorOption(additionalConfigFunc ...func(*validatorengine.Validate)) StructValidatorOptionFunc

SetCoreStructValidatorOption option func

type Validator

type Validator struct {
	JSONSchema      *JSONSchemaValidator
	StructValidator *StructValidator
}

Validator instance

func NewValidator

func NewValidator(opts ...OptionFunc) *Validator

NewValidator constructor, using jsonschema & struct validator (github.com/go-playground/validator), jsonschema source file load from "api/jsonschema" directory

func (*Validator) ValidateDocument added in v1.14.0

func (v *Validator) ValidateDocument(reference string, document any) error

ValidateDocument method using jsonschema with input is json source

func (*Validator) ValidateStruct added in v1.14.0

func (v *Validator) ValidateStruct(data any) error

ValidateStruct method, rules from struct tag using github.com/go-playground/validator

Jump to

Keyboard shortcuts

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