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
NewFileLocalStorage read from file
func NewFileSystemStorage ¶ added in v1.17.9
NewFileSystemStorage constructor
func NewInMemStorage ¶ added in v1.11.15
NewInMemStorage constructor
type StructValidator ¶
type StructValidatorOptionFunc ¶ added in v1.14.0
type StructValidatorOptionFunc func(StructValidator)
StructValidatorOptionFunc type
type Validator ¶
type Validator struct {
JSONSchema *JSONSchemaValidator
StructValidator StructValidator
}
Validator instance
func NewValidator ¶
func NewValidator(opts ...OptionFunc) *Validator
NewValidator constructor, using jsonschema jsonschema source file load from "api/jsonschema" directory
func (*Validator) ValidateDocument ¶ added in v1.14.0
ValidateDocument method using jsonschema with input is json source
func (*Validator) ValidateStruct ¶ added in v1.14.0
ValidateStruct method, rules from struct