Documentation ¶
Overview ¶
Package jsonschema implements request validator with github.com/santhosh-tekuri/jsonschema/v2.
Index ¶
- type Factory
- type Validator
- func (v *Validator) AddSchema(in rest.ParamIn, name string, jsonSchema []byte, required bool) error
- func (v *Validator) ForbidUnknownParams(in rest.ParamIn, forbidden bool)
- func (v *Validator) HasConstraints(in rest.ParamIn) bool
- func (v *Validator) ValidateData(in rest.ParamIn, namedData map[string]interface{}) error
- func (v *Validator) ValidateJSONBody(jsonBody []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Factory ¶
type Factory struct { // JSONMarshal controls custom marshaler, nil value enables "encoding/json". JSONMarshal func(interface{}) ([]byte, error) // contains filtered or unexported fields }
Factory makes JSON Schema request validators.
Please use NewFactory to create an instance.
func NewFactory ¶
func NewFactory( requestSchemas rest.RequestJSONSchemaProvider, responseSchemas rest.ResponseJSONSchemaProvider, ) Factory
NewFactory creates new validator factory.
func (Factory) MakeRequestValidator ¶
func (f Factory) MakeRequestValidator( method string, input interface{}, mapping rest.RequestMapping, ) rest.Validator
MakeRequestValidator creates request validator for HTTP method and input structure.
type Validator ¶
type Validator struct { // JSONMarshal controls custom marshaler, nil value enables "encoding/json". JSONMarshal func(interface{}) ([]byte, error) // contains filtered or unexported fields }
Validator is a JSON Schema based validator.
func (*Validator) ForbidUnknownParams ¶ added in v0.2.26
ForbidUnknownParams configures if unknown parameters should be forbidden.
func (*Validator) HasConstraints ¶ added in v0.1.3
HasConstraints indicates if there are validation rules for parameter location.
func (*Validator) ValidateData ¶
ValidateData performs validation of a mapped request data.
func (*Validator) ValidateJSONBody ¶
ValidateJSONBody performs validation of JSON body.
Click to show internal directories.
Click to hide internal directories.