validator

package
v1.11.26 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// RegexAlphabetLower const
	RegexAlphabetLower = "a-z"
	// RegexAlphabetUpper const
	RegexAlphabetUpper = "A-Z"
	// RegexNumeric const
	RegexNumeric = "0-9"
	// RegexDash const
	RegexDash = "-"

	// AlphabetLower const
	AlphabetLower = "alfabet kecil"
	// AlphabetUpper const
	AlphabetUpper = "alfabet besar"
	// Numeric const
	Numeric = "numerik"
	// Dash const
	Dash = "strip"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONSchemaValidator

type JSONSchemaValidator struct {
	SchemaStorage        Storage
	NotShowErrorListType map[string]bool
}

JSONSchemaValidator validator

func NewJSONSchemaValidator

func NewJSONSchemaValidator(schemaRootPath string) *JSONSchemaValidator

NewJSONSchemaValidator constructor

func (*JSONSchemaValidator) ValidateDocument

func (v *JSONSchemaValidator) ValidateDocument(schemaID string, documentSource interface{}) error

ValidateDocument based on schema id

type Storage added in v1.11.15

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

Storage abstraction

func NewInMemStorage added in v1.11.15

func NewInMemStorage(rootDir string) Storage

NewInMemStorage constructor

func NewLocalStorage added in v1.11.15

func NewLocalStorage(rootDir string) Storage

NewLocalStorage read from file

type StructValidator

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

StructValidator struct

func NewStructValidator

func NewStructValidator() *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 interface{}) error

ValidateStruct function

type Validator

type Validator struct {
	*JSONSchemaValidator
	*StructValidator
}

Validator instance

func NewValidator

func NewValidator() *Validator

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

Jump to

Keyboard shortcuts

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