...

Package jsonschema

import "github.com/qri-io/jsonschema"
Overview
Index

Overview ▾

Index ▾

Variables
func DataType(data interface{}) string
func DataTypeWithHint(data interface{}, hint string) string
func FetchSchema(ctx context.Context, uri string, schema *Schema) error
func GetKeywordInsertOrder(prop string) int
func GetKeywordOrder(prop string) int
func InvalidValueString(data interface{}) string
func IsLocalSchemaID(id string) bool
func IsNotSupportedKeyword(prop string) bool
func IsRegisteredKeyword(prop string) bool
func IsRegistryLoaded() bool
func LoadDraft2019_09()
func RegisterKeyword(prop string, maker KeyMaker)
func ResetSchemaRegistry()
func SafeResolveURL(ctxURL, resURL string) (string, error)
func SetKeywordOrder(prop string, order int)
type AdditionalItems
    func (ai *AdditionalItems) Register(uri string, registry *SchemaRegistry)
    func (ai *AdditionalItems) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (ai *AdditionalItems) UnmarshalJSON(data []byte) error
    func (ai *AdditionalItems) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type AdditionalProperties
    func (ap *AdditionalProperties) Register(uri string, registry *SchemaRegistry)
    func (ap *AdditionalProperties) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (ap *AdditionalProperties) UnmarshalJSON(data []byte) error
    func (ap *AdditionalProperties) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type AllOf
    func (a AllOf) JSONChildren() (res map[string]JSONPather)
    func (a AllOf) JSONProp(name string) interface{}
    func (a *AllOf) Register(uri string, registry *SchemaRegistry)
    func (a *AllOf) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (a *AllOf) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Anchor
    func (a *Anchor) Register(uri string, registry *SchemaRegistry)
    func (a *Anchor) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (a *Anchor) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type AnyOf
    func (a AnyOf) JSONChildren() (res map[string]JSONPather)
    func (a AnyOf) JSONProp(name string) interface{}
    func (a *AnyOf) Register(uri string, registry *SchemaRegistry)
    func (a *AnyOf) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (a *AnyOf) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Comment
    func (c *Comment) Register(uri string, registry *SchemaRegistry)
    func (c *Comment) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (c *Comment) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Const
    func (c Const) JSONProp(name string) interface{}
    func (c Const) MarshalJSON() ([]byte, error)
    func (c *Const) Register(uri string, registry *SchemaRegistry)
    func (c *Const) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (c Const) String() string
    func (c *Const) UnmarshalJSON(data []byte) error
    func (c Const) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Contains
    func (c Contains) JSONChildren() (res map[string]JSONPather)
    func (c Contains) JSONProp(name string) interface{}
    func (c *Contains) Register(uri string, registry *SchemaRegistry)
    func (c *Contains) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (c *Contains) UnmarshalJSON(data []byte) error
    func (c *Contains) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Default
    func (d *Default) Register(uri string, registry *SchemaRegistry)
    func (d *Default) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (d *Default) UnmarshalJSON(data []byte) error
    func (d *Default) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Defs
    func (d Defs) JSONChildren() (res map[string]JSONPather)
    func (d Defs) JSONProp(name string) interface{}
    func (d *Defs) Register(uri string, registry *SchemaRegistry)
    func (d *Defs) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (d Defs) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type DependentRequired
    func (d DependentRequired) JSONChildren() (r map[string]JSONPather)
    func (d DependentRequired) JSONProp(name string) interface{}
    func (d DependentRequired) MarshalJSON() ([]byte, error)
    func (d *DependentRequired) Register(uri string, registry *SchemaRegistry)
    func (d *DependentRequired) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (d *DependentRequired) UnmarshalJSON(data []byte) error
    func (d *DependentRequired) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type DependentSchemas
    func (d DependentSchemas) JSONChildren() (r map[string]JSONPather)
    func (d DependentSchemas) JSONProp(name string) interface{}
    func (d *DependentSchemas) Register(uri string, registry *SchemaRegistry)
    func (d *DependentSchemas) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (d *DependentSchemas) UnmarshalJSON(data []byte) error
    func (d *DependentSchemas) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Description
    func (d *Description) Register(uri string, registry *SchemaRegistry)
    func (d *Description) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (d *Description) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Else
    func (e Else) JSONChildren() (res map[string]JSONPather)
    func (e Else) JSONProp(name string) interface{}
    func (e Else) MarshalJSON() ([]byte, error)
    func (e *Else) Register(uri string, registry *SchemaRegistry)
    func (e *Else) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (e *Else) UnmarshalJSON(data []byte) error
    func (e *Else) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Enum
    func (e Enum) JSONChildren() (res map[string]JSONPather)
    func (e Enum) JSONProp(name string) interface{}
    func (e *Enum) Register(uri string, registry *SchemaRegistry)
    func (e *Enum) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (e Enum) String() string
    func (e Enum) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Examples
    func (e *Examples) Register(uri string, registry *SchemaRegistry)
    func (e *Examples) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (e *Examples) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type ExclusiveMaximum
    func (m *ExclusiveMaximum) Register(uri string, registry *SchemaRegistry)
    func (m *ExclusiveMaximum) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (m ExclusiveMaximum) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type ExclusiveMinimum
    func (m *ExclusiveMinimum) Register(uri string, registry *SchemaRegistry)
    func (m *ExclusiveMinimum) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (m ExclusiveMinimum) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Format
    func (f *Format) Register(uri string, registry *SchemaRegistry)
    func (f *Format) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (f Format) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type ID
    func (i *ID) Register(uri string, registry *SchemaRegistry)
    func (i *ID) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (i *ID) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type If
    func (f If) JSONChildren() (res map[string]JSONPather)
    func (f If) JSONProp(name string) interface{}
    func (f If) MarshalJSON() ([]byte, error)
    func (f *If) Register(uri string, registry *SchemaRegistry)
    func (f *If) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (f *If) UnmarshalJSON(data []byte) error
    func (f *If) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Items
    func (it Items) JSONChildren() (res map[string]JSONPather)
    func (it Items) JSONProp(name string) interface{}
    func (it Items) MarshalJSON() ([]byte, error)
    func (it *Items) Register(uri string, registry *SchemaRegistry)
    func (it *Items) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (it *Items) UnmarshalJSON(data []byte) error
    func (it Items) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type JSONContainer
type JSONPather
type KeyError
    func (v KeyError) Error() string
type KeyMaker
type Keyword
    func GetKeyword(prop string) Keyword
    func NewAdditionalItems() Keyword
    func NewAdditionalProperties() Keyword
    func NewAllOf() Keyword
    func NewAnchor() Keyword
    func NewAnyOf() Keyword
    func NewComment() Keyword
    func NewConst() Keyword
    func NewContains() Keyword
    func NewDefault() Keyword
    func NewDefs() Keyword
    func NewDependentRequired() Keyword
    func NewDependentSchemas() Keyword
    func NewDescription() Keyword
    func NewElse() Keyword
    func NewEnum() Keyword
    func NewExamples() Keyword
    func NewExclusiveMaximum() Keyword
    func NewExclusiveMinimum() Keyword
    func NewFormat() Keyword
    func NewID() Keyword
    func NewIf() Keyword
    func NewItems() Keyword
    func NewMaxContains() Keyword
    func NewMaxItems() Keyword
    func NewMaxLength() Keyword
    func NewMaxProperties() Keyword
    func NewMaximum() Keyword
    func NewMinContains() Keyword
    func NewMinItems() Keyword
    func NewMinLength() Keyword
    func NewMinProperties() Keyword
    func NewMinimum() Keyword
    func NewMultipleOf() Keyword
    func NewNot() Keyword
    func NewOneOf() Keyword
    func NewPattern() Keyword
    func NewPatternProperties() Keyword
    func NewProperties() Keyword
    func NewPropertyNames() Keyword
    func NewReadOnly() Keyword
    func NewRecursiveAnchor() Keyword
    func NewRecursiveRef() Keyword
    func NewRef() Keyword
    func NewRequired() Keyword
    func NewSchema() Keyword
    func NewSchemaURI() Keyword
    func NewThen() Keyword
    func NewTitle() Keyword
    func NewType() Keyword
    func NewUnevaluatedItems() Keyword
    func NewUnevaluatedProperties() Keyword
    func NewUniqueItems() Keyword
    func NewVoid() Keyword
    func NewWriteOnly() Keyword
type MaxContains
    func (m *MaxContains) Register(uri string, registry *SchemaRegistry)
    func (m *MaxContains) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (m MaxContains) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type MaxItems
    func (m *MaxItems) Register(uri string, registry *SchemaRegistry)
    func (m *MaxItems) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (m MaxItems) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type MaxLength
    func (m *MaxLength) Register(uri string, registry *SchemaRegistry)
    func (m *MaxLength) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (m MaxLength) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type MaxProperties
    func (m *MaxProperties) Register(uri string, registry *SchemaRegistry)
    func (m *MaxProperties) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (m MaxProperties) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Maximum
    func (m *Maximum) Register(uri string, registry *SchemaRegistry)
    func (m *Maximum) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (m Maximum) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type MinContains
    func (m *MinContains) Register(uri string, registry *SchemaRegistry)
    func (m *MinContains) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (m MinContains) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type MinItems
    func (m *MinItems) Register(uri string, registry *SchemaRegistry)
    func (m *MinItems) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (m MinItems) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type MinLength
    func (m *MinLength) Register(uri string, registry *SchemaRegistry)
    func (m *MinLength) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (m MinLength) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type MinProperties
    func (m *MinProperties) Register(uri string, registry *SchemaRegistry)
    func (m *MinProperties) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (m MinProperties) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Minimum
    func (m *Minimum) Register(uri string, registry *SchemaRegistry)
    func (m *Minimum) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (m Minimum) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type MultipleOf
    func (m *MultipleOf) Register(uri string, registry *SchemaRegistry)
    func (m *MultipleOf) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (m MultipleOf) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Not
    func (n Not) JSONChildren() (res map[string]JSONPather)
    func (n Not) JSONProp(name string) interface{}
    func (n Not) MarshalJSON() ([]byte, error)
    func (n *Not) Register(uri string, registry *SchemaRegistry)
    func (n *Not) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (n *Not) UnmarshalJSON(data []byte) error
    func (n *Not) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type OneOf
    func (o OneOf) JSONChildren() (res map[string]JSONPather)
    func (o OneOf) JSONProp(name string) interface{}
    func (o *OneOf) Register(uri string, registry *SchemaRegistry)
    func (o *OneOf) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (o *OneOf) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Pattern
    func (p Pattern) MarshalJSON() ([]byte, error)
    func (p *Pattern) Register(uri string, registry *SchemaRegistry)
    func (p *Pattern) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (p *Pattern) UnmarshalJSON(data []byte) error
    func (p Pattern) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type PatternProperties
    func (p PatternProperties) JSONChildren() (res map[string]JSONPather)
    func (p PatternProperties) JSONProp(name string) interface{}
    func (p PatternProperties) MarshalJSON() ([]byte, error)
    func (p *PatternProperties) Register(uri string, registry *SchemaRegistry)
    func (p *PatternProperties) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (p *PatternProperties) UnmarshalJSON(data []byte) error
    func (p PatternProperties) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Properties
    func (p Properties) JSONChildren() (res map[string]JSONPather)
    func (p Properties) JSONProp(name string) interface{}
    func (p *Properties) Register(uri string, registry *SchemaRegistry)
    func (p *Properties) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (p Properties) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type PropertyDependency
    func (p PropertyDependency) JSONProp(name string) interface{}
    func (p *PropertyDependency) Register(uri string, registry *SchemaRegistry)
    func (p *PropertyDependency) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (p *PropertyDependency) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type PropertyNames
    func (p PropertyNames) JSONChildren() (res map[string]JSONPather)
    func (p PropertyNames) JSONProp(name string) interface{}
    func (p PropertyNames) MarshalJSON() ([]byte, error)
    func (p *PropertyNames) Register(uri string, registry *SchemaRegistry)
    func (p *PropertyNames) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (p *PropertyNames) UnmarshalJSON(data []byte) error
    func (p *PropertyNames) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type ReadOnly
    func (r *ReadOnly) Register(uri string, registry *SchemaRegistry)
    func (r *ReadOnly) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (r *ReadOnly) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type RecursiveAnchor
    func (r *RecursiveAnchor) Register(uri string, registry *SchemaRegistry)
    func (r *RecursiveAnchor) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (r *RecursiveAnchor) UnmarshalJSON(data []byte) error
    func (r *RecursiveAnchor) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type RecursiveRef
    func (r RecursiveRef) MarshalJSON() ([]byte, error)
    func (r *RecursiveRef) Register(uri string, registry *SchemaRegistry)
    func (r *RecursiveRef) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (r *RecursiveRef) UnmarshalJSON(data []byte) error
    func (r *RecursiveRef) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Ref
    func (r Ref) MarshalJSON() ([]byte, error)
    func (r *Ref) Register(uri string, registry *SchemaRegistry)
    func (r *Ref) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (r *Ref) UnmarshalJSON(data []byte) error
    func (r *Ref) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Required
    func (r Required) JSONProp(name string) interface{}
    func (r *Required) Register(uri string, registry *SchemaRegistry)
    func (r *Required) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (r Required) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Schema
    func Must(jsonString string) *Schema
    func (s *Schema) HasKeyword(key string) bool
    func (s Schema) JSONChildren() map[string]JSONPather
    func (s Schema) JSONProp(name string) interface{}
    func (s Schema) MarshalJSON() ([]byte, error)
    func (s *Schema) Register(uri string, registry *SchemaRegistry)
    func (s *Schema) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (s *Schema) TopLevelType() string
    func (s *Schema) UnmarshalJSON(data []byte) error
    func (s *Schema) Validate(ctx context.Context, data interface{}) *ValidationState
    func (s *Schema) ValidateBytes(ctx context.Context, data []byte) ([]KeyError, error)
    func (s *Schema) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type SchemaDependency
    func (d SchemaDependency) JSONProp(name string) interface{}
    func (d SchemaDependency) MarshalJSON() ([]byte, error)
    func (d *SchemaDependency) Register(uri string, registry *SchemaRegistry)
    func (d *SchemaDependency) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (d *SchemaDependency) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type SchemaRegistry
    func GetSchemaRegistry() *SchemaRegistry
    func (sr *SchemaRegistry) Get(ctx context.Context, uri string) *Schema
    func (sr *SchemaRegistry) GetKnown(uri string) *Schema
    func (sr *SchemaRegistry) GetLocal(uri string) *Schema
    func (sr *SchemaRegistry) Register(sch *Schema)
    func (sr *SchemaRegistry) RegisterLocal(sch *Schema)
type SchemaURI
    func (s *SchemaURI) Register(uri string, registry *SchemaRegistry)
    func (s *SchemaURI) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (s *SchemaURI) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Then
    func (t Then) JSONChildren() (res map[string]JSONPather)
    func (t Then) JSONProp(name string) interface{}
    func (t Then) MarshalJSON() ([]byte, error)
    func (t *Then) Register(uri string, registry *SchemaRegistry)
    func (t *Then) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (t *Then) UnmarshalJSON(data []byte) error
    func (t *Then) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Title
    func (t *Title) Register(uri string, registry *SchemaRegistry)
    func (t *Title) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (t *Title) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type Type
    func (t Type) JSONProp(name string) interface{}
    func (t Type) MarshalJSON() ([]byte, error)
    func (t *Type) Register(uri string, registry *SchemaRegistry)
    func (t *Type) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (t Type) String() string
    func (t *Type) UnmarshalJSON(data []byte) error
    func (t Type) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type UnevaluatedItems
    func (ui *UnevaluatedItems) Register(uri string, registry *SchemaRegistry)
    func (ui *UnevaluatedItems) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (ui *UnevaluatedItems) UnmarshalJSON(data []byte) error
    func (ui *UnevaluatedItems) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type UnevaluatedProperties
    func (up *UnevaluatedProperties) Register(uri string, registry *SchemaRegistry)
    func (up *UnevaluatedProperties) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (up *UnevaluatedProperties) UnmarshalJSON(data []byte) error
    func (up *UnevaluatedProperties) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type UniqueItems
    func (u *UniqueItems) Register(uri string, registry *SchemaRegistry)
    func (u *UniqueItems) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (u UniqueItems) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type ValidationState
    func NewValidationState(s *Schema) *ValidationState
    func (vs *ValidationState) AddError(data interface{}, msg string)
    func (vs *ValidationState) AddSubErrors(errs ...KeyError)
    func (vs *ValidationState) ClearState()
    func (vs *ValidationState) DescendBase(token ...string)
    func (vs *ValidationState) DescendBaseFromState(base *ValidationState, token ...string)
    func (vs *ValidationState) DescendInstance(token ...string)
    func (vs *ValidationState) DescendInstanceFromState(base *ValidationState, token ...string)
    func (vs *ValidationState) DescendRelative(token ...string)
    func (vs *ValidationState) DescendRelativeFromState(base *ValidationState, token ...string)
    func (vs *ValidationState) IsEvaluatedKey(key string) bool
    func (vs *ValidationState) IsLocallyEvaluatedKey(key string) bool
    func (vs *ValidationState) IsValid() bool
    func (vs *ValidationState) NewSubState() *ValidationState
    func (vs *ValidationState) SetEvaluatedIndex(i int)
    func (vs *ValidationState) SetEvaluatedKey(key string)
    func (vs *ValidationState) UpdateEvaluatedPropsAndItems(subState *ValidationState)
type Void
    func (vo *Void) Register(uri string, registry *SchemaRegistry)
    func (vo *Void) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (vo *Void) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
type WriteOnly
    func (w *WriteOnly) Register(uri string, registry *SchemaRegistry)
    func (w *WriteOnly) Resolve(pointer jptr.Pointer, uri string) *Schema
    func (w *WriteOnly) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

Package files

draft2019_09_keywords.go keyword.go keywords_array.go keywords_boolean.go keywords_conditional.go keywords_core.go keywords_numeric.go keywords_object.go keywords_optional.go keywords_standard.go keywords_string.go schema.go schema_registry.go traversal.go util.go validation_state.go

Variables

MaxKeywordErrStringLen sets how long a value can be before it's length is truncated when printing error strings a special value of -1 disables output trimming

var MaxKeywordErrStringLen = 20

func DataType

func DataType(data interface{}) string

DataType attempts to parse the underlying data type from the raw data interface

func DataTypeWithHint

func DataTypeWithHint(data interface{}, hint string) string

DataTypeWithHint attempts to parse the underlying data type by leveraging the schema expectations for better results

func FetchSchema

func FetchSchema(ctx context.Context, uri string, schema *Schema) error

FetchSchema downloads and loads a schema from a remote location

func GetKeywordInsertOrder

func GetKeywordInsertOrder(prop string) int

GetKeywordInsertOrder returns the insert index of the given keyword

func GetKeywordOrder

func GetKeywordOrder(prop string) int

GetKeywordOrder returns the order index of the given keyword or defaults to 1

func InvalidValueString

func InvalidValueString(data interface{}) string

InvalidValueString returns the errored value as a string

func IsLocalSchemaID

func IsLocalSchemaID(id string) bool

IsLocalSchemaID validates if a given id is a local id

func IsNotSupportedKeyword

func IsNotSupportedKeyword(prop string) bool

IsNotSupportedKeyword is a utility function to clarify when a given keyword, while expected is not supported

func IsRegisteredKeyword

func IsRegisteredKeyword(prop string) bool

IsRegisteredKeyword validates if a given prop string is a registered keyword

func IsRegistryLoaded

func IsRegistryLoaded() bool

IsRegistryLoaded checks if any keywords are present

func LoadDraft2019_09

func LoadDraft2019_09()

LoadDraft2019_09 loads the keywords for schema validation based on draft2019_09 this is also the default keyword set loaded automatically if no other is loaded

func RegisterKeyword

func RegisterKeyword(prop string, maker KeyMaker)

RegisterKeyword registers a keyword with the registry

func ResetSchemaRegistry

func ResetSchemaRegistry()

ResetSchemaRegistry resets the main SchemaRegistry

func SafeResolveURL

func SafeResolveURL(ctxURL, resURL string) (string, error)

SafeResolveURL resolves a string url against the current context url

func SetKeywordOrder

func SetKeywordOrder(prop string, order int)

SetKeywordOrder assignes a given order to a keyword

type AdditionalItems

AdditionalItems defines the additionalItems JSON Schema keyword

type AdditionalItems Schema

func (*AdditionalItems) Register

func (ai *AdditionalItems) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for AdditionalItems

func (*AdditionalItems) Resolve

func (ai *AdditionalItems) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for AdditionalItems

func (*AdditionalItems) UnmarshalJSON

func (ai *AdditionalItems) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for AdditionalItems

func (*AdditionalItems) ValidateKeyword

func (ai *AdditionalItems) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for AdditionalItems

type AdditionalProperties

AdditionalProperties defines the additionalProperties JSON Schema keyword

type AdditionalProperties Schema

func (*AdditionalProperties) Register

func (ap *AdditionalProperties) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for AdditionalProperties

func (*AdditionalProperties) Resolve

func (ap *AdditionalProperties) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for AdditionalProperties

func (*AdditionalProperties) UnmarshalJSON

func (ap *AdditionalProperties) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for AdditionalProperties

func (*AdditionalProperties) ValidateKeyword

func (ap *AdditionalProperties) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for AdditionalProperties

type AllOf

AllOf defines the allOf JSON Schema keyword

type AllOf []*Schema

func (AllOf) JSONChildren

func (a AllOf) JSONChildren() (res map[string]JSONPather)

JSONChildren implements the JSONContainer interface for AllOf

func (AllOf) JSONProp

func (a AllOf) JSONProp(name string) interface{}

JSONProp implements the JSONPather for AllOf

func (*AllOf) Register

func (a *AllOf) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for AllOf

func (*AllOf) Resolve

func (a *AllOf) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for AllOf

func (*AllOf) ValidateKeyword

func (a *AllOf) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for AllOf

type Anchor

Anchor defines the $anchor JSON Schema keyword

type Anchor string

func (*Anchor) Register

func (a *Anchor) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Anchor

func (*Anchor) Resolve

func (a *Anchor) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Anchor

func (*Anchor) ValidateKeyword

func (a *Anchor) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Anchor

type AnyOf

AnyOf defines the anyOf JSON Schema keyword

type AnyOf []*Schema

func (AnyOf) JSONChildren

func (a AnyOf) JSONChildren() (res map[string]JSONPather)

JSONChildren implements the JSONContainer interface for AnyOf

func (AnyOf) JSONProp

func (a AnyOf) JSONProp(name string) interface{}

JSONProp implements the JSONPather for AnyOf

func (*AnyOf) Register

func (a *AnyOf) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for AnyOf

func (*AnyOf) Resolve

func (a *AnyOf) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for AnyOf

func (*AnyOf) ValidateKeyword

func (a *AnyOf) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for AnyOf

type Comment

Comment defines the comment JSON Schema keyword

type Comment string

func (*Comment) Register

func (c *Comment) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Comment

func (*Comment) Resolve

func (c *Comment) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Comment

func (*Comment) ValidateKeyword

func (c *Comment) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Comment

type Const

Const defines the const JSON Schema keyword

type Const json.RawMessage

func (Const) JSONProp

func (c Const) JSONProp(name string) interface{}

JSONProp implements the JSONPather for Const

func (Const) MarshalJSON

func (c Const) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Const

func (*Const) Register

func (c *Const) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Const

func (*Const) Resolve

func (c *Const) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Const

func (Const) String

func (c Const) String() string

String implements the Stringer for Const

func (*Const) UnmarshalJSON

func (c *Const) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Const

func (Const) ValidateKeyword

func (c Const) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Const

type Contains

Contains defines the contains JSON Schema keyword

type Contains Schema

func (Contains) JSONChildren

func (c Contains) JSONChildren() (res map[string]JSONPather)

JSONChildren implements the JSONContainer interface for Contains

func (Contains) JSONProp

func (c Contains) JSONProp(name string) interface{}

JSONProp implements the JSONPather for Contains

func (*Contains) Register

func (c *Contains) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Contains

func (*Contains) Resolve

func (c *Contains) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Contains

func (*Contains) UnmarshalJSON

func (c *Contains) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Contains

func (*Contains) ValidateKeyword

func (c *Contains) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Contains

type Default

Default defines the default JSON Schema keyword

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

func (*Default) Register

func (d *Default) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Default

func (*Default) Resolve

func (d *Default) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Default

func (*Default) UnmarshalJSON

func (d *Default) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Default

func (*Default) ValidateKeyword

func (d *Default) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Default

type Defs

Defs defines the $defs JSON Schema keyword

type Defs map[string]*Schema

func (Defs) JSONChildren

func (d Defs) JSONChildren() (res map[string]JSONPather)

JSONChildren implements the JSONContainer interface for Defs

func (Defs) JSONProp

func (d Defs) JSONProp(name string) interface{}

JSONProp implements the JSONPather for Defs

func (*Defs) Register

func (d *Defs) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Defs

func (*Defs) Resolve

func (d *Defs) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Defs

func (Defs) ValidateKeyword

func (d Defs) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Defs

type DependentRequired

DependentRequired defines the dependentRequired JSON Schema keyword

type DependentRequired map[string]PropertyDependency

func (DependentRequired) JSONChildren

func (d DependentRequired) JSONChildren() (r map[string]JSONPather)

JSONChildren implements the JSONContainer interface for DependentRequired

func (DependentRequired) JSONProp

func (d DependentRequired) JSONProp(name string) interface{}

JSONProp implements the JSONPather for DependentRequired

func (DependentRequired) MarshalJSON

func (d DependentRequired) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for DependentRequired

func (*DependentRequired) Register

func (d *DependentRequired) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for DependentRequired

func (*DependentRequired) Resolve

func (d *DependentRequired) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for DependentRequired

func (*DependentRequired) UnmarshalJSON

func (d *DependentRequired) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for DependentRequired

func (*DependentRequired) ValidateKeyword

func (d *DependentRequired) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for DependentRequired

type DependentSchemas

DependentSchemas defines the dependentSchemas JSON Schema keyword

type DependentSchemas map[string]SchemaDependency

func (DependentSchemas) JSONChildren

func (d DependentSchemas) JSONChildren() (r map[string]JSONPather)

JSONChildren implements the JSONContainer interface for DependentSchemas

func (DependentSchemas) JSONProp

func (d DependentSchemas) JSONProp(name string) interface{}

JSONProp implements the JSONPather for DependentSchemas

func (*DependentSchemas) Register

func (d *DependentSchemas) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for DependentSchemas

func (*DependentSchemas) Resolve

func (d *DependentSchemas) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for DependentSchemas

func (*DependentSchemas) UnmarshalJSON

func (d *DependentSchemas) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for DependentSchemas

func (*DependentSchemas) ValidateKeyword

func (d *DependentSchemas) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for DependentSchemas

type Description

Description defines the description JSON Schema keyword

type Description string

func (*Description) Register

func (d *Description) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Description

func (*Description) Resolve

func (d *Description) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Description

func (*Description) ValidateKeyword

func (d *Description) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Description

type Else

Else defines the else JSON Schema keyword

type Else Schema

func (Else) JSONChildren

func (e Else) JSONChildren() (res map[string]JSONPather)

JSONChildren implements the JSONContainer interface for Else

func (Else) JSONProp

func (e Else) JSONProp(name string) interface{}

JSONProp implements the JSONPather for Else

func (Else) MarshalJSON

func (e Else) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Else

func (*Else) Register

func (e *Else) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Else

func (*Else) Resolve

func (e *Else) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Else

func (*Else) UnmarshalJSON

func (e *Else) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Else

func (*Else) ValidateKeyword

func (e *Else) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Else

type Enum

Enum defines the enum JSON Schema keyword

type Enum []Const

func (Enum) JSONChildren

func (e Enum) JSONChildren() (res map[string]JSONPather)

JSONChildren implements the JSONContainer interface for Enum

func (Enum) JSONProp

func (e Enum) JSONProp(name string) interface{}

JSONProp implements the JSONPather for Enum

func (*Enum) Register

func (e *Enum) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Enum

func (*Enum) Resolve

func (e *Enum) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Enum

func (Enum) String

func (e Enum) String() string

String implements the Stringer for Enum

func (Enum) ValidateKeyword

func (e Enum) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Enum

type Examples

Examples defines the examples JSON Schema keyword

type Examples []interface{}

func (*Examples) Register

func (e *Examples) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Examples

func (*Examples) Resolve

func (e *Examples) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Examples

func (*Examples) ValidateKeyword

func (e *Examples) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Examples

type ExclusiveMaximum

ExclusiveMaximum defines the exclusiveMaximum JSON Schema keyword

type ExclusiveMaximum float64

func (*ExclusiveMaximum) Register

func (m *ExclusiveMaximum) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for ExclusiveMaximum

func (*ExclusiveMaximum) Resolve

func (m *ExclusiveMaximum) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for ExclusiveMaximum

func (ExclusiveMaximum) ValidateKeyword

func (m ExclusiveMaximum) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for ExclusiveMaximum

type ExclusiveMinimum

ExclusiveMinimum defines the exclusiveMinimum JSON Schema keyword

type ExclusiveMinimum float64

func (*ExclusiveMinimum) Register

func (m *ExclusiveMinimum) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for ExclusiveMinimum

func (*ExclusiveMinimum) Resolve

func (m *ExclusiveMinimum) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for ExclusiveMinimum

func (ExclusiveMinimum) ValidateKeyword

func (m ExclusiveMinimum) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for ExclusiveMinimum

type Format

Format defines the format JSON Schema keyword

type Format string

func (*Format) Register

func (f *Format) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Format

func (*Format) Resolve

func (f *Format) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Format

func (Format) ValidateKeyword

func (f Format) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Format

type ID

ID defines the $id JSON Schema keyword

type ID string

func (*ID) Register

func (i *ID) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for ID

func (*ID) Resolve

func (i *ID) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for ID

func (*ID) ValidateKeyword

func (i *ID) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for ID

type If

If defines the if JSON Schema keyword

type If Schema

func (If) JSONChildren

func (f If) JSONChildren() (res map[string]JSONPather)

JSONChildren implements the JSONContainer interface for If

func (If) JSONProp

func (f If) JSONProp(name string) interface{}

JSONProp implements the JSONPather for If

func (If) MarshalJSON

func (f If) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for If

func (*If) Register

func (f *If) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for If

func (*If) Resolve

func (f *If) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for If

func (*If) UnmarshalJSON

func (f *If) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for If

func (*If) ValidateKeyword

func (f *If) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for If

type Items

Items defines the items JSON Schema keyword

type Items struct {
    Schemas []*Schema
    // contains filtered or unexported fields
}

func (Items) JSONChildren

func (it Items) JSONChildren() (res map[string]JSONPather)

JSONChildren implements the JSONContainer interface for Items

func (Items) JSONProp

func (it Items) JSONProp(name string) interface{}

JSONProp implements the JSONPather for Items

func (Items) MarshalJSON

func (it Items) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Items

func (*Items) Register

func (it *Items) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Items

func (*Items) Resolve

func (it *Items) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Items

func (*Items) UnmarshalJSON

func (it *Items) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Items

func (Items) ValidateKeyword

func (it Items) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Items

type JSONContainer

JSONContainer is an interface that enables tree traversal by listing the immideate children of an object

type JSONContainer interface {
    // JSONChildren should return all immidiate children of this element
    JSONChildren() map[string]JSONPather
}

type JSONPather

JSONPather makes validators traversible by JSON-pointers, which is required to support references in JSON schemas.

type JSONPather interface {
    // JSONProp take a string references for a given JSON property
    // implementations must return any matching property of that name
    // or nil if no such subproperty exists.
    // Note this also applies to array values, which are expected to interpret
    // valid numbers as an array index
    JSONProp(name string) interface{}
}

type KeyError

KeyError represents a single error in an instance of a schema The only absolutely-required property is Message.

type KeyError struct {
    // PropertyPath is a string path that leads to the
    // property that produced the error
    PropertyPath string `json:"propertyPath,omitempty"`
    // InvalidValue is the value that returned the error
    InvalidValue interface{} `json:"invalidValue,omitempty"`
    // Message is a human-readable description of the error
    Message string `json:"message"`
}

func (KeyError) Error

func (v KeyError) Error() string

Error implements the error interface for KeyError

type KeyMaker

KeyMaker is a function that generates instances of a Keyword. Calls to KeyMaker will be passed directly to json.Marshal, so the returned value should be a pointer

type KeyMaker func() Keyword

type Keyword

Keyword is an interface for anything that can validate. JSON-Schema keywords are all examples of Keyword

type Keyword interface {
    // ValidateKeyword checks decoded JSON data and writes
    // validation errors (if any) to an outparam slice of KeyErrors
    ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

    // Register builds up the schema tree by evaluating the current key
    // and the current location pointer which is later used with resolve to
    // navigate the schema tree and substitute the propper schema for a given
    // reference.
    Register(uri string, registry *SchemaRegistry)
    // Resolve unraps a pointer to the destination schema
    // It usually starts with a $ref validation call which
    // uses the pointer token by token to navigate the
    // schema tree to get to the last schema in the chain.
    // Since every keyword can have it's specifics around resolving
    // each keyword need to implement it's own version of Resolve.
    // Terminal keywords should respond with nil as it's not a schema
    // Keywords that wrap a schema should return the appropriate schema.
    // In case of a non-existing location it will fail to resolve, return nil
    // on ref resolution and error out.
    Resolve(pointer jptr.Pointer, uri string) *Schema
}

func GetKeyword

func GetKeyword(prop string) Keyword

GetKeyword returns a new instance of the keyword

func NewAdditionalItems

func NewAdditionalItems() Keyword

NewAdditionalItems allocates a new AdditionalItems keyword

func NewAdditionalProperties

func NewAdditionalProperties() Keyword

NewAdditionalProperties allocates a new AdditionalProperties keyword

func NewAllOf

func NewAllOf() Keyword

NewAllOf allocates a new AllOf keyword

func NewAnchor

func NewAnchor() Keyword

NewAnchor allocates a new Anchor keyword

func NewAnyOf

func NewAnyOf() Keyword

NewAnyOf allocates a new AnyOf keyword

func NewComment

func NewComment() Keyword

NewComment allocates a new Comment keyword

func NewConst

func NewConst() Keyword

NewConst allocates a new Const keyword

func NewContains

func NewContains() Keyword

NewContains allocates a new Contains keyword

func NewDefault

func NewDefault() Keyword

NewDefault allocates a new Default keyword

func NewDefs

func NewDefs() Keyword

NewDefs allocates a new Defs keyword

func NewDependentRequired

func NewDependentRequired() Keyword

NewDependentRequired allocates a new DependentRequired keyword

func NewDependentSchemas

func NewDependentSchemas() Keyword

NewDependentSchemas allocates a new DependentSchemas keyword

func NewDescription

func NewDescription() Keyword

NewDescription allocates a new Description keyword

func NewElse

func NewElse() Keyword

NewElse allocates a new Else keyword

func NewEnum

func NewEnum() Keyword

NewEnum allocates a new Enum keyword

func NewExamples

func NewExamples() Keyword

NewExamples allocates a new Examples keyword

func NewExclusiveMaximum

func NewExclusiveMaximum() Keyword

NewExclusiveMaximum allocates a new ExclusiveMaximum keyword

func NewExclusiveMinimum

func NewExclusiveMinimum() Keyword

NewExclusiveMinimum allocates a new ExclusiveMinimum keyword

func NewFormat

func NewFormat() Keyword

NewFormat allocates a new Format keyword

func NewID

func NewID() Keyword

NewID allocates a new Id keyword

func NewIf

func NewIf() Keyword

NewIf allocates a new If keyword

func NewItems

func NewItems() Keyword

NewItems allocates a new Items keyword

func NewMaxContains

func NewMaxContains() Keyword

NewMaxContains allocates a new MaxContains keyword

func NewMaxItems

func NewMaxItems() Keyword

NewMaxItems allocates a new MaxItems keyword

func NewMaxLength

func NewMaxLength() Keyword

NewMaxLength allocates a new MaxLength keyword

func NewMaxProperties

func NewMaxProperties() Keyword

NewMaxProperties allocates a new MaxProperties keyword

func NewMaximum

func NewMaximum() Keyword

NewMaximum allocates a new Maximum keyword

func NewMinContains

func NewMinContains() Keyword

NewMinContains allocates a new MinContains keyword

func NewMinItems

func NewMinItems() Keyword

NewMinItems allocates a new MinItems keyword

func NewMinLength

func NewMinLength() Keyword

NewMinLength allocates a new MinLength keyword

func NewMinProperties

func NewMinProperties() Keyword

NewMinProperties allocates a new MinProperties keyword

func NewMinimum

func NewMinimum() Keyword

NewMinimum allocates a new Minimum keyword

func NewMultipleOf

func NewMultipleOf() Keyword

NewMultipleOf allocates a new MultipleOf keyword

func NewNot

func NewNot() Keyword

NewNot allocates a new Not keyword

func NewOneOf

func NewOneOf() Keyword

NewOneOf allocates a new OneOf keyword

func NewPattern

func NewPattern() Keyword

NewPattern allocates a new Pattern keyword

func NewPatternProperties

func NewPatternProperties() Keyword

NewPatternProperties allocates a new PatternProperties keyword

func NewProperties

func NewProperties() Keyword

NewProperties allocates a new Properties keyword

func NewPropertyNames

func NewPropertyNames() Keyword

NewPropertyNames allocates a new PropertyNames keyword

func NewReadOnly

func NewReadOnly() Keyword

NewReadOnly allocates a new ReadOnly keyword

func NewRecursiveAnchor

func NewRecursiveAnchor() Keyword

NewRecursiveAnchor allocates a new RecursiveAnchor keyword

func NewRecursiveRef

func NewRecursiveRef() Keyword

NewRecursiveRef allocates a new RecursiveRef keyword

func NewRef

func NewRef() Keyword

NewRef allocates a new Ref keyword

func NewRequired

func NewRequired() Keyword

NewRequired allocates a new Required keyword

func NewSchema

func NewSchema() Keyword

NewSchema allocates a new Schema Keyword/Validator

func NewSchemaURI

func NewSchemaURI() Keyword

NewSchemaURI allocates a new SchemaURI keyword

func NewThen

func NewThen() Keyword

NewThen allocates a new Then keyword

func NewTitle

func NewTitle() Keyword

NewTitle allocates a new Title keyword

func NewType

func NewType() Keyword

NewType allocates a new Type keyword

func NewUnevaluatedItems

func NewUnevaluatedItems() Keyword

NewUnevaluatedItems allocates a new UnevaluatedItems keyword

func NewUnevaluatedProperties

func NewUnevaluatedProperties() Keyword

NewUnevaluatedProperties allocates a new UnevaluatedProperties keyword

func NewUniqueItems

func NewUniqueItems() Keyword

NewUniqueItems allocates a new UniqueItems keyword

func NewVoid

func NewVoid() Keyword

NewVoid allocates a new Void keyword

func NewWriteOnly

func NewWriteOnly() Keyword

NewWriteOnly allocates a new WriteOnly keyword

type MaxContains

MaxContains defines the maxContains JSON Schema keyword

type MaxContains int

func (*MaxContains) Register

func (m *MaxContains) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for MaxContains

func (*MaxContains) Resolve

func (m *MaxContains) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for MaxContains

func (MaxContains) ValidateKeyword

func (m MaxContains) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for MaxContains

type MaxItems

MaxItems defines the maxItems JSON Schema keyword

type MaxItems int

func (*MaxItems) Register

func (m *MaxItems) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for MaxItems

func (*MaxItems) Resolve

func (m *MaxItems) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for MaxItems

func (MaxItems) ValidateKeyword

func (m MaxItems) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for MaxItems

type MaxLength

MaxLength defines the maxLenght JSON Schema keyword

type MaxLength int

func (*MaxLength) Register

func (m *MaxLength) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for MaxLength

func (*MaxLength) Resolve

func (m *MaxLength) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for MaxLength

func (MaxLength) ValidateKeyword

func (m MaxLength) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for MaxLength

type MaxProperties

MaxProperties defines the maxProperties JSON Schema keyword

type MaxProperties int

func (*MaxProperties) Register

func (m *MaxProperties) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for MaxProperties

func (*MaxProperties) Resolve

func (m *MaxProperties) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for MaxProperties

func (MaxProperties) ValidateKeyword

func (m MaxProperties) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for MaxProperties

type Maximum

Maximum defines the maximum JSON Schema keyword

type Maximum float64

func (*Maximum) Register

func (m *Maximum) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Maximum

func (*Maximum) Resolve

func (m *Maximum) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Maximum

func (Maximum) ValidateKeyword

func (m Maximum) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Maximum

type MinContains

MinContains defines the minContains JSON Schema keyword

type MinContains int

func (*MinContains) Register

func (m *MinContains) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for MinContains

func (*MinContains) Resolve

func (m *MinContains) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for MinContains

func (MinContains) ValidateKeyword

func (m MinContains) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for MinContains

type MinItems

MinItems defines the minItems JSON Schema keyword

type MinItems int

func (*MinItems) Register

func (m *MinItems) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for MinItems

func (*MinItems) Resolve

func (m *MinItems) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for MinItems

func (MinItems) ValidateKeyword

func (m MinItems) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for MinItems

type MinLength

MinLength defines the maxLenght JSON Schema keyword

type MinLength int

func (*MinLength) Register

func (m *MinLength) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for MinLength

func (*MinLength) Resolve

func (m *MinLength) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for MinLength

func (MinLength) ValidateKeyword

func (m MinLength) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for MinLength

type MinProperties

MinProperties defines the minProperties JSON Schema keyword

type MinProperties int

func (*MinProperties) Register

func (m *MinProperties) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for MinProperties

func (*MinProperties) Resolve

func (m *MinProperties) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for MinProperties

func (MinProperties) ValidateKeyword

func (m MinProperties) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for MinProperties

type Minimum

Minimum defines the minimum JSON Schema keyword

type Minimum float64

func (*Minimum) Register

func (m *Minimum) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Minimum

func (*Minimum) Resolve

func (m *Minimum) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Minimum

func (Minimum) ValidateKeyword

func (m Minimum) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Minimum

type MultipleOf

MultipleOf defines the multipleOf JSON Schema keyword

type MultipleOf float64

func (*MultipleOf) Register

func (m *MultipleOf) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for MultipleOf

func (*MultipleOf) Resolve

func (m *MultipleOf) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for MultipleOf

func (MultipleOf) ValidateKeyword

func (m MultipleOf) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for MultipleOf

type Not

Not defines the not JSON Schema keyword

type Not Schema

func (Not) JSONChildren

func (n Not) JSONChildren() (res map[string]JSONPather)

JSONChildren implements the JSONContainer interface for Not

func (Not) JSONProp

func (n Not) JSONProp(name string) interface{}

JSONProp implements the JSONPather for Not

func (Not) MarshalJSON

func (n Not) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Not

func (*Not) Register

func (n *Not) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Not

func (*Not) Resolve

func (n *Not) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Not

func (*Not) UnmarshalJSON

func (n *Not) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Not

func (*Not) ValidateKeyword

func (n *Not) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Not

type OneOf

OneOf defines the oneOf JSON Schema keyword

type OneOf []*Schema

func (OneOf) JSONChildren

func (o OneOf) JSONChildren() (res map[string]JSONPather)

JSONChildren implements the JSONContainer interface for OneOf

func (OneOf) JSONProp

func (o OneOf) JSONProp(name string) interface{}

JSONProp implements the JSONPather for OneOf

func (*OneOf) Register

func (o *OneOf) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for OneOf

func (*OneOf) Resolve

func (o *OneOf) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for OneOf

func (*OneOf) ValidateKeyword

func (o *OneOf) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for OneOf

type Pattern

Pattern defines the pattern JSON Schema keyword

type Pattern regexp.Regexp

func (Pattern) MarshalJSON

func (p Pattern) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Pattern

func (*Pattern) Register

func (p *Pattern) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Pattern

func (*Pattern) Resolve

func (p *Pattern) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Pattern

func (*Pattern) UnmarshalJSON

func (p *Pattern) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Pattern

func (Pattern) ValidateKeyword

func (p Pattern) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Pattern

type PatternProperties

PatternProperties defines the patternProperties JSON Schema keyword

type PatternProperties []patternSchema

func (PatternProperties) JSONChildren

func (p PatternProperties) JSONChildren() (res map[string]JSONPather)

JSONChildren implements the JSONContainer interface for PatternProperties

func (PatternProperties) JSONProp

func (p PatternProperties) JSONProp(name string) interface{}

JSONProp implements the JSONPather for PatternProperties

func (PatternProperties) MarshalJSON

func (p PatternProperties) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for PatternProperties

func (*PatternProperties) Register

func (p *PatternProperties) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for PatternProperties

func (*PatternProperties) Resolve

func (p *PatternProperties) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for PatternProperties

func (*PatternProperties) UnmarshalJSON

func (p *PatternProperties) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for PatternProperties

func (PatternProperties) ValidateKeyword

func (p PatternProperties) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for PatternProperties

type Properties

Properties defines the properties JSON Schema keyword

type Properties map[string]*Schema

func (Properties) JSONChildren

func (p Properties) JSONChildren() (res map[string]JSONPather)

JSONChildren implements the JSONContainer interface for Properties

func (Properties) JSONProp

func (p Properties) JSONProp(name string) interface{}

JSONProp implements the JSONPather for Properties

func (*Properties) Register

func (p *Properties) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Properties

func (*Properties) Resolve

func (p *Properties) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Properties

func (Properties) ValidateKeyword

func (p Properties) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Properties

type PropertyDependency

PropertyDependency is the internal representation of a dependent property

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

func (PropertyDependency) JSONProp

func (p PropertyDependency) JSONProp(name string) interface{}

JSONProp implements the JSONPather for PropertyDependency

func (*PropertyDependency) Register

func (p *PropertyDependency) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for PropertyDependency

func (*PropertyDependency) Resolve

func (p *PropertyDependency) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for PropertyDependency

func (*PropertyDependency) ValidateKeyword

func (p *PropertyDependency) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for PropertyDependency

type PropertyNames

PropertyNames defines the propertyNames JSON Schema keyword

type PropertyNames Schema

func (PropertyNames) JSONChildren

func (p PropertyNames) JSONChildren() (res map[string]JSONPather)

JSONChildren implements the JSONContainer interface for PropertyNames

func (PropertyNames) JSONProp

func (p PropertyNames) JSONProp(name string) interface{}

JSONProp implements the JSONPather for PropertyNames

func (PropertyNames) MarshalJSON

func (p PropertyNames) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for PropertyNames

func (*PropertyNames) Register

func (p *PropertyNames) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for PropertyNames

func (*PropertyNames) Resolve

func (p *PropertyNames) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for PropertyNames

func (*PropertyNames) UnmarshalJSON

func (p *PropertyNames) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for PropertyNames

func (*PropertyNames) ValidateKeyword

func (p *PropertyNames) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for PropertyNames

type ReadOnly

ReadOnly defines the readOnly JSON Schema keyword

type ReadOnly bool

func (*ReadOnly) Register

func (r *ReadOnly) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for ReadOnly

func (*ReadOnly) Resolve

func (r *ReadOnly) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for ReadOnly

func (*ReadOnly) ValidateKeyword

func (r *ReadOnly) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for ReadOnly

type RecursiveAnchor

RecursiveAnchor defines the $recursiveAnchor JSON Schema keyword

type RecursiveAnchor Schema

func (*RecursiveAnchor) Register

func (r *RecursiveAnchor) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for RecursiveAnchor

func (*RecursiveAnchor) Resolve

func (r *RecursiveAnchor) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for RecursiveAnchor

func (*RecursiveAnchor) UnmarshalJSON

func (r *RecursiveAnchor) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for RecursiveAnchor

func (*RecursiveAnchor) ValidateKeyword

func (r *RecursiveAnchor) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for RecursiveAnchor

type RecursiveRef

RecursiveRef defines the $recursiveRef JSON Schema keyword

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

func (RecursiveRef) MarshalJSON

func (r RecursiveRef) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for RecursiveRef

func (*RecursiveRef) Register

func (r *RecursiveRef) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for RecursiveRef

func (*RecursiveRef) Resolve

func (r *RecursiveRef) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for RecursiveRef

func (*RecursiveRef) UnmarshalJSON

func (r *RecursiveRef) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for RecursiveRef

func (*RecursiveRef) ValidateKeyword

func (r *RecursiveRef) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for RecursiveRef

type Ref

Ref defines the $ref JSON Schema keyword

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

func (Ref) MarshalJSON

func (r Ref) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Ref

func (*Ref) Register

func (r *Ref) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Ref

func (*Ref) Resolve

func (r *Ref) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Ref

func (*Ref) UnmarshalJSON

func (r *Ref) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Ref

func (*Ref) ValidateKeyword

func (r *Ref) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Ref

type Required

Required defines the required JSON Schema keyword

type Required []string

func (Required) JSONProp

func (r Required) JSONProp(name string) interface{}

JSONProp implements the JSONPather for Required

func (*Required) Register

func (r *Required) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Required

func (*Required) Resolve

func (r *Required) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Required

func (Required) ValidateKeyword

func (r Required) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Required

type Schema

Schema is the top-level structure defining a json schema

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

func Must

func Must(jsonString string) *Schema

Must turns a JSON string into a *Schema, panicing if parsing fails. Useful for declaring Schemas in Go code.

func (*Schema) HasKeyword

func (s *Schema) HasKeyword(key string) bool

HasKeyword is a utility function for checking if the given schema has an instance of the required keyword

func (Schema) JSONChildren

func (s Schema) JSONChildren() map[string]JSONPather

JSONChildren implements the JSONContainer interface for Schema

func (Schema) JSONProp

func (s Schema) JSONProp(name string) interface{}

JSONProp implements the JSONPather for Schema

func (Schema) MarshalJSON

func (s Schema) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Schema

func (*Schema) Register

func (s *Schema) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Schema

func (*Schema) Resolve

func (s *Schema) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Schema

func (*Schema) TopLevelType

func (s *Schema) TopLevelType() string

TopLevelType returns a string representing the schema's top-level type.

func (*Schema) UnmarshalJSON

func (s *Schema) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Schema

func (*Schema) Validate

func (s *Schema) Validate(ctx context.Context, data interface{}) *ValidationState

Validate initiates a fresh validation state and triggers the evaluation

func (*Schema) ValidateBytes

func (s *Schema) ValidateBytes(ctx context.Context, data []byte) ([]KeyError, error)

ValidateBytes performs schema validation against a slice of json byte data

func (*Schema) ValidateKeyword

func (s *Schema) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword uses the schema to check an instance, collecting validation errors in a slice

type SchemaDependency

SchemaDependency is the internal representation of a dependent schema

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

func (SchemaDependency) JSONProp

func (d SchemaDependency) JSONProp(name string) interface{}

JSONProp implements the JSONPather for SchemaDependency

func (SchemaDependency) MarshalJSON

func (d SchemaDependency) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for SchemaDependency

func (*SchemaDependency) Register

func (d *SchemaDependency) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for SchemaDependency

func (*SchemaDependency) Resolve

func (d *SchemaDependency) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for SchemaDependency

func (*SchemaDependency) ValidateKeyword

func (d *SchemaDependency) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for SchemaDependency

type SchemaRegistry

SchemaRegistry maintains a lookup table between schema string references and actual schemas

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

func GetSchemaRegistry

func GetSchemaRegistry() *SchemaRegistry

GetSchemaRegistry provides an accessor to a globally available schema registry

func (*SchemaRegistry) Get

func (sr *SchemaRegistry) Get(ctx context.Context, uri string) *Schema

Get fetches a schema from the top level context registry or fetches it from a remote

func (*SchemaRegistry) GetKnown

func (sr *SchemaRegistry) GetKnown(uri string) *Schema

GetKnown fetches a schema from the top level context registry

func (*SchemaRegistry) GetLocal

func (sr *SchemaRegistry) GetLocal(uri string) *Schema

GetLocal fetches a schema from the local context registry

func (*SchemaRegistry) Register

func (sr *SchemaRegistry) Register(sch *Schema)

Register registers a schema to the top level context

func (*SchemaRegistry) RegisterLocal

func (sr *SchemaRegistry) RegisterLocal(sch *Schema)

RegisterLocal registers a schema to a local context

type SchemaURI

SchemaURI defines the $schema JSON Schema keyword

type SchemaURI string

func (*SchemaURI) Register

func (s *SchemaURI) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for SchemaURI

func (*SchemaURI) Resolve

func (s *SchemaURI) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for SchemaURI

func (*SchemaURI) ValidateKeyword

func (s *SchemaURI) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for SchemaURI

type Then

Then defines the then JSON Schema keyword

type Then Schema

func (Then) JSONChildren

func (t Then) JSONChildren() (res map[string]JSONPather)

JSONChildren implements the JSONContainer interface for Then

func (Then) JSONProp

func (t Then) JSONProp(name string) interface{}

JSONProp implements the JSONPather for Then

func (Then) MarshalJSON

func (t Then) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Then

func (*Then) Register

func (t *Then) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Then

func (*Then) Resolve

func (t *Then) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Then

func (*Then) UnmarshalJSON

func (t *Then) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Then

func (*Then) ValidateKeyword

func (t *Then) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Then

type Title

Title defines the title JSON Schema keyword

type Title string

func (*Title) Register

func (t *Title) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Title

func (*Title) Resolve

func (t *Title) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Title

func (*Title) ValidateKeyword

func (t *Title) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Title

type Type

Type defines the type JSON Schema keyword

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

func (Type) JSONProp

func (t Type) JSONProp(name string) interface{}

JSONProp implements the JSONPather for Type

func (Type) MarshalJSON

func (t Type) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Type

func (*Type) Register

func (t *Type) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Type

func (*Type) Resolve

func (t *Type) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Type

func (Type) String

func (t Type) String() string

String implements the Stringer for Type

func (*Type) UnmarshalJSON

func (t *Type) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Type

func (Type) ValidateKeyword

func (t Type) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Type

type UnevaluatedItems

UnevaluatedItems defines the unevaluatedItems JSON Schema keyword

type UnevaluatedItems Schema

func (*UnevaluatedItems) Register

func (ui *UnevaluatedItems) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for UnevaluatedItems

func (*UnevaluatedItems) Resolve

func (ui *UnevaluatedItems) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for UnevaluatedItems

func (*UnevaluatedItems) UnmarshalJSON

func (ui *UnevaluatedItems) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for UnevaluatedItems

func (*UnevaluatedItems) ValidateKeyword

func (ui *UnevaluatedItems) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for UnevaluatedItems

type UnevaluatedProperties

UnevaluatedProperties defines the unevaluatedProperties JSON Schema keyword

type UnevaluatedProperties Schema

func (*UnevaluatedProperties) Register

func (up *UnevaluatedProperties) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for UnevaluatedProperties

func (*UnevaluatedProperties) Resolve

func (up *UnevaluatedProperties) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for UnevaluatedProperties

func (*UnevaluatedProperties) UnmarshalJSON

func (up *UnevaluatedProperties) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for UnevaluatedProperties

func (*UnevaluatedProperties) ValidateKeyword

func (up *UnevaluatedProperties) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for UnevaluatedProperties

type UniqueItems

UniqueItems defines the uniqueItems JSON Schema keyword

type UniqueItems bool

func (*UniqueItems) Register

func (u *UniqueItems) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for UniqueItems

func (*UniqueItems) Resolve

func (u *UniqueItems) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for UniqueItems

func (UniqueItems) ValidateKeyword

func (u UniqueItems) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for UniqueItems

type ValidationState

ValidationState holds the schema validation state The aim is to have one global validation state and use local sub states when evaluating parallel branches TODO(arqu): make sure this is safe for concurrent use

type ValidationState struct {
    Local                *Schema
    Root                 *Schema
    RecursiveAnchor      *Schema
    BaseURI              string
    InstanceLocation     *jptr.Pointer
    RelativeLocation     *jptr.Pointer
    BaseRelativeLocation *jptr.Pointer

    LocalRegistry *SchemaRegistry

    EvaluatedPropertyNames      *map[string]bool
    LocalEvaluatedPropertyNames *map[string]bool
    LastEvaluatedIndex          int
    LocalLastEvaluatedIndex     int
    Misc                        map[string]interface{}

    Errs *[]KeyError
}

func NewValidationState

func NewValidationState(s *Schema) *ValidationState

NewValidationState creates a new ValidationState with the provided location pointers and data instance

func (*ValidationState) AddError

func (vs *ValidationState) AddError(data interface{}, msg string)

AddError creates and appends a KeyError to errs of the current state

func (*ValidationState) AddSubErrors

func (vs *ValidationState) AddSubErrors(errs ...KeyError)

AddSubErrors appends a list of KeyError to the current state

func (*ValidationState) ClearState

func (vs *ValidationState) ClearState()

ClearState resets a schema to it's core elements

func (*ValidationState) DescendBase

func (vs *ValidationState) DescendBase(token ...string)

DescendBase descends the base relative pointer relative to itself

func (*ValidationState) DescendBaseFromState

func (vs *ValidationState) DescendBaseFromState(base *ValidationState, token ...string)

DescendBaseFromState descends the base relative pointer relative to the provided state

func (*ValidationState) DescendInstance

func (vs *ValidationState) DescendInstance(token ...string)

DescendInstance descends the instance pointer relative to itself

func (*ValidationState) DescendInstanceFromState

func (vs *ValidationState) DescendInstanceFromState(base *ValidationState, token ...string)

DescendInstanceFromState descends the instance pointer relative to the provided state

func (*ValidationState) DescendRelative

func (vs *ValidationState) DescendRelative(token ...string)

DescendRelative descends the relative pointer relative to itself

func (*ValidationState) DescendRelativeFromState

func (vs *ValidationState) DescendRelativeFromState(base *ValidationState, token ...string)

DescendRelativeFromState descends the relative pointer relative to the provided state

func (*ValidationState) IsEvaluatedKey

func (vs *ValidationState) IsEvaluatedKey(key string) bool

IsEvaluatedKey checks if the key is evaluated against the state context

func (*ValidationState) IsLocallyEvaluatedKey

func (vs *ValidationState) IsLocallyEvaluatedKey(key string) bool

IsLocallyEvaluatedKey checks if the key is evaluated against the local state context

func (*ValidationState) IsValid

func (vs *ValidationState) IsValid() bool

IsValid returns if the current state is valid

func (*ValidationState) NewSubState

func (vs *ValidationState) NewSubState() *ValidationState

NewSubState creates a new ValidationState from an existing ValidationState

func (*ValidationState) SetEvaluatedIndex

func (vs *ValidationState) SetEvaluatedIndex(i int)

SetEvaluatedIndex sets the evaluation index for the current state

func (*ValidationState) SetEvaluatedKey

func (vs *ValidationState) SetEvaluatedKey(key string)

SetEvaluatedKey updates the evaluation properties of the current state

func (*ValidationState) UpdateEvaluatedPropsAndItems

func (vs *ValidationState) UpdateEvaluatedPropsAndItems(subState *ValidationState)

UpdateEvaluatedPropsAndItems is a utility function to join evaluated properties and set the current evaluation position index

type Void

Void is a placeholder definition for a keyword

type Void struct{}

func (*Void) Register

func (vo *Void) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for Void

func (*Void) Resolve

func (vo *Void) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for Void

func (*Void) ValidateKeyword

func (vo *Void) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for Void

type WriteOnly

WriteOnly defines the writeOnly JSON Schema keyword

type WriteOnly bool

func (*WriteOnly) Register

func (w *WriteOnly) Register(uri string, registry *SchemaRegistry)

Register implements the Keyword interface for WriteOnly

func (*WriteOnly) Resolve

func (w *WriteOnly) Resolve(pointer jptr.Pointer, uri string) *Schema

Resolve implements the Keyword interface for WriteOnly

func (*WriteOnly) ValidateKeyword

func (w *WriteOnly) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})

ValidateKeyword implements the Keyword interface for WriteOnly