Documentation ¶
Index ¶
- func InitJsonSchemaLoader()
- type IJSONSchema
- type JSONSchema
- func (js *JSONSchema) HasSchema(filename string) bool
- func (js *JSONSchema) LoadSchema(filename string) (gojsonschema.JSONLoader, error)
- func (js *JSONSchema) SetSchemaRootDirectory(dirname string) error
- func (js *JSONSchema) ValidateBind(schema string, req *http.Request, s interface{}) (*JSONValidationResult, error)
- func (js *JSONSchema) ValidateBindRaw(schema string, data *[]byte, s interface{}) (*JSONValidationResult, error)
- type JSONValidationErrors
- type JSONValidationResult
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 JSONValidationResult ¶
type JSONValidationResult struct {
Errors []JSONValidationErrors `json:"errors"`
}
Click to show internal directories.
Click to hide internal directories.