Documentation ¶
Index ¶
- Constants
- 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
- 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
- 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
- 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
- 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
- type ExclusiveMaximum
- type ExclusiveMinimum
- type Format
- type ID
- 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
- 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
- type MaxItems
- type MaxLength
- type MaxProperties
- type Maximum
- type MinContains
- type MinItems
- type MinLength
- type MinProperties
- type Minimum
- type MultipleOf
- 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) Get(key string) (*Schema, bool)
- 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) UnmarshalJSON(data []byte) error
- func (p Properties) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
- type Property
- 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
- 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) ResolveRef(rootSchema *Schema) *Schema
- func (r *Ref) UnmarshalJSON(data []byte) error
- func (r *Ref) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
- type Required
- type 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
- type SchemaURI
- 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
- 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
- type 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
- type WriteOnly
Constants ¶
const ( SchemaTypeObject schemaType = iota SchemaTypeFalse SchemaTypeTrue )
Variables ¶
var MaxKeywordErrStringLen = 20
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
Functions ¶
func DataType ¶
func DataType(data interface{}) string
DataType attempts to parse the underlying data type from the raw data interface
func DataTypeWithHint ¶
DataTypeWithHint attempts to parse the underlying data type by leveraging the schema expectations for better results
func FetchSchema ¶
FetchSchema downloads and loads a schema from a remote location
func GetKeywordInsertOrder ¶
GetKeywordInsertOrder returns the insert index of the given keyword
func GetKeywordOrder ¶
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 ¶
IsLocalSchemaID validates if a given Id is a local Id
func IsNotSupportedKeyword ¶
IsNotSupportedKeyword is a utility function to clarify when a given keyword, while expected is not supported
func IsRegisteredKeyword ¶
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 ¶
RegisterKeyword registers a keyword with the registry
func ResetSchemaRegistry ¶
func ResetSchemaRegistry()
ResetSchemaRegistry resets the main SchemaRegistry
func SafeResolveURL ¶
SafeResolveURL resolves a string url against the current context url
func SetKeywordOrder ¶
SetKeywordOrder assignes a given order to a keyword
Types ¶
type AdditionalItems ¶
type AdditionalItems Schema
AdditionalItems defines the additionalItems JSON Schema keyword
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 ¶
type AdditionalProperties Schema
AdditionalProperties defines the additionalProperties JSON Schema keyword
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 ¶
type AllOf []*Schema
AllOf defines the allOf JSON Schema keyword
func (AllOf) JSONChildren ¶
func (a AllOf) JSONChildren() (res map[string]JSONPather)
JSONChildren implements the JSONContainer interface for AllOf
func (*AllOf) Register ¶
func (a *AllOf) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type Anchor string
Anchor defines the $anchor JSON Schema keyword
func (*Anchor) Register ¶
func (a *Anchor) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type AnyOf []*Schema
AnyOf defines the anyOf JSON Schema keyword
func (AnyOf) JSONChildren ¶
func (a AnyOf) JSONChildren() (res map[string]JSONPather)
JSONChildren implements the JSONContainer interface for AnyOf
func (*AnyOf) Register ¶
func (a *AnyOf) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type Comment string
Comment defines the comment JSON Schema keyword
func (*Comment) Register ¶
func (c *Comment) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type Const json.RawMessage
Const defines the const JSON Schema keyword
func (Const) MarshalJSON ¶
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) UnmarshalJSON ¶
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 ¶
type Contains Schema
Contains defines the contains JSON Schema keyword
func (Contains) JSONChildren ¶
func (c Contains) JSONChildren() (res map[string]JSONPather)
JSONChildren implements the JSONContainer interface for Contains
func (*Contains) Register ¶
func (c *Contains) Register(uri string, registry *SchemaRegistry)
Register implements the Keyword interface for Contains
func (*Contains) UnmarshalJSON ¶
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 ¶
type Default struct {
Data interface{}
}
Default defines the default JSON Schema keyword
func (*Default) Register ¶
func (d *Default) Register(uri string, registry *SchemaRegistry)
Register implements the Keyword interface for Default
func (*Default) UnmarshalJSON ¶
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
func (Defs) JSONChildren ¶
func (d Defs) JSONChildren() (res map[string]JSONPather)
JSONChildren implements the JSONContainer interface for Defs
func (*Defs) Register ¶
func (d *Defs) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type DependentRequired map[string]PropertyDependency
DependentRequired defines the dependentRequired JSON Schema keyword
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 ¶
type DependentSchemas map[string]SchemaDependency
DependentSchemas defines the dependentSchemas JSON Schema keyword
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 ¶
type Description string
Description defines the description JSON Schema keyword
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 ¶
type Else Schema
Else defines the else JSON Schema keyword
func (Else) JSONChildren ¶
func (e Else) JSONChildren() (res map[string]JSONPather)
JSONChildren implements the JSONContainer interface for Else
func (Else) MarshalJSON ¶
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) UnmarshalJSON ¶
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 ¶
type Enum []Const
Enum defines the enum JSON Schema keyword
func (Enum) JSONChildren ¶
func (e Enum) JSONChildren() (res map[string]JSONPather)
JSONChildren implements the JSONContainer interface for Enum
func (*Enum) Register ¶
func (e *Enum) Register(uri string, registry *SchemaRegistry)
Register implements the Keyword interface 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 ¶
type Examples []interface{}
Examples defines the examples JSON Schema keyword
func (*Examples) Register ¶
func (e *Examples) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type ExclusiveMaximum float64
ExclusiveMaximum defines the exclusiveMaximum JSON Schema keyword
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 ¶
type ExclusiveMinimum float64
ExclusiveMinimum defines the exclusiveMinimum JSON Schema keyword
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 ¶
type Format string
Format defines the format JSON Schema keyword
func (*Format) Register ¶
func (f *Format) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type ID string
ID defines the $Id JSON Schema keyword
func (*ID) Register ¶
func (i *ID) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type If Schema
If defines the if JSON Schema keyword
func (If) JSONChildren ¶
func (f If) JSONChildren() (res map[string]JSONPather)
JSONChildren implements the JSONContainer interface for If
func (If) MarshalJSON ¶
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) UnmarshalJSON ¶
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
func (Items) JSONChildren ¶
func (it Items) JSONChildren() (res map[string]JSONPather)
JSONChildren implements the JSONContainer interface for Items
func (Items) MarshalJSON ¶
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) UnmarshalJSON ¶
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 ¶
type JSONContainer interface { // JSONChildren should return all immidiate children of this element JSONChildren() map[string]JSONPather }
JSONContainer is an interface that enables tree traversal by listing the immideate children of an object
type JSONPather ¶
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{} }
JSONPather makes validators traversible by JSON-pointers, which is required to support references in JSON schemas.
type KeyError ¶
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"` }
KeyError represents a Single error in an instance of a schema The only absolutely-required property is Message.
type KeyMaker ¶
type KeyMaker func() Keyword
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 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 }
Keyword is an interface for anything that can validate. JSON-Schema Keywords are all examples of Keyword
func GetKeyword ¶
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 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 NewExclusiveMaximum ¶
func NewExclusiveMaximum() Keyword
NewExclusiveMaximum allocates a new ExclusiveMaximum keyword
func NewExclusiveMinimum ¶
func NewExclusiveMinimum() Keyword
NewExclusiveMinimum allocates a new ExclusiveMinimum keyword
func NewMaxContains ¶
func NewMaxContains() Keyword
NewMaxContains allocates a new MaxContains keyword
func NewMaxProperties ¶
func NewMaxProperties() Keyword
NewMaxProperties allocates a new MaxProperties keyword
func NewMinContains ¶
func NewMinContains() Keyword
NewMinContains allocates a new MinContains keyword
func NewMinProperties ¶
func NewMinProperties() Keyword
NewMinProperties allocates a new MinProperties keyword
func NewPatternProperties ¶
func NewPatternProperties() Keyword
NewPatternProperties allocates a new PatternProperties keyword
func NewPropertyNames ¶
func NewPropertyNames() Keyword
NewPropertyNames allocates a new PropertyNames keyword
func NewRecursiveAnchor ¶
func NewRecursiveAnchor() Keyword
NewRecursiveAnchor allocates a new RecursiveAnchor keyword
func NewRecursiveRef ¶
func NewRecursiveRef() Keyword
NewRecursiveRef allocates a new RecursiveRef 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
type MaxContains ¶
type MaxContains int
MaxContains defines the maxContains JSON Schema keyword
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 ¶
type MaxItems int
MaxItems defines the maxItems JSON Schema keyword
func (*MaxItems) Register ¶
func (m *MaxItems) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type MaxLength int
MaxLength defines the maxLenght JSON Schema keyword
func (*MaxLength) Register ¶
func (m *MaxLength) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type MaxProperties int
MaxProperties defines the maxProperties JSON Schema keyword
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 ¶
type Maximum float64
Maximum defines the maximum JSON Schema keyword
func (*Maximum) Register ¶
func (m *Maximum) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type MinContains int
MinContains defines the minContains JSON Schema keyword
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 ¶
type MinItems int
MinItems defines the minItems JSON Schema keyword
func (*MinItems) Register ¶
func (m *MinItems) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type MinLength int
MinLength defines the maxLenght JSON Schema keyword
func (*MinLength) Register ¶
func (m *MinLength) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type MinProperties int
MinProperties defines the minProperties JSON Schema keyword
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 ¶
type Minimum float64
Minimum defines the minimum JSON Schema keyword
func (*Minimum) Register ¶
func (m *Minimum) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type MultipleOf float64
MultipleOf defines the multipleOf JSON Schema keyword
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 ¶
type Not Schema
Not defines the not JSON Schema keyword
func (Not) JSONChildren ¶
func (n Not) JSONChildren() (res map[string]JSONPather)
JSONChildren implements the JSONContainer interface for Not
func (Not) MarshalJSON ¶
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) UnmarshalJSON ¶
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 ¶
type OneOf []*Schema
OneOf defines the oneOf JSON Schema keyword
func (OneOf) JSONChildren ¶
func (o OneOf) JSONChildren() (res map[string]JSONPather)
JSONChildren implements the JSONContainer interface for OneOf
func (*OneOf) Register ¶
func (o *OneOf) Register(uri string, registry *SchemaRegistry)
Register 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
func (Pattern) MarshalJSON ¶
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) UnmarshalJSON ¶
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 ¶
type PatternProperties []patternSchema
PatternProperties defines the patternProperties JSON Schema keyword
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 ¶
type Properties []Property
Properties defines the properties JSON Schema keyword
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) UnmarshalJSON ¶
func (p *Properties) UnmarshalJSON(data []byte) error
func (Properties) ValidateKeyword ¶
func (p Properties) ValidateKeyword(ctx context.Context, currentState *ValidationState, data interface{})
ValidateKeyword implements the Keyword interface for Properties
type PropertyDependency ¶
type PropertyDependency struct {
// contains filtered or unexported fields
}
PropertyDependency is the internal representation of a dependent property
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 ¶
type PropertyNames Schema
PropertyNames defines the propertyNames JSON Schema keyword
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 ¶
type ReadOnly bool
ReadOnly defines the readOnly JSON Schema keyword
func (*ReadOnly) Register ¶
func (r *ReadOnly) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type RecursiveAnchor Schema
RecursiveAnchor defines the $recursiveAnchor JSON Schema keyword
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 ¶
type RecursiveRef struct { Reference string // contains filtered or unexported fields }
RecursiveRef defines the $recursiveRef JSON Schema keyword
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 ¶
type Ref struct { Reference string // contains filtered or unexported fields }
Ref defines the $ref JSON Schema keyword
func (Ref) MarshalJSON ¶
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) ResolveRef ¶ added in v0.7.5
ResolveRef attempts to resolve the reference and return the resolved schema
func (*Ref) UnmarshalJSON ¶
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 ¶
type Required []string
Required defines the required JSON Schema keyword
func (*Required) Register ¶
func (r *Required) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type Schema struct { SchemaType schemaType DocPath string HasRegistered bool Id string ExtraDefinitions map[string]json.RawMessage Keywords map[string]Keyword OrderedKeywords []string }
Schema is the top-level structure defining a json schema
func Must ¶
Must turns a JSON string into a *Schema, panicing if parsing fails. Useful for declaring Schemas in Go code.
func (*Schema) HasKeyword ¶
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) MarshalJSON ¶
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) TopLevelType ¶
TopLevelType returns a string representing the schema's top-level type.
func (*Schema) UnmarshalJSON ¶
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 ¶
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 ¶
type SchemaDependency struct {
// contains filtered or unexported fields
}
SchemaDependency is the internal representation of a dependent schema
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 ¶
type SchemaRegistry struct {
// contains filtered or unexported fields
}
SchemaRegistry maintains a lookup table between schema string references and actual schemas
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 ¶
type SchemaURI string
SchemaURI defines the $schema JSON Schema keyword
func (*SchemaURI) Register ¶
func (s *SchemaURI) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type Then Schema
Then defines the then JSON Schema keyword
func (Then) JSONChildren ¶
func (t Then) JSONChildren() (res map[string]JSONPather)
JSONChildren implements the JSONContainer interface for Then
func (Then) MarshalJSON ¶
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) UnmarshalJSON ¶
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 ¶
type Title string
Title defines the title JSON Schema keyword
func (*Title) Register ¶
func (t *Title) Register(uri string, registry *SchemaRegistry)
Register 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
func (Type) MarshalJSON ¶
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) UnmarshalJSON ¶
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 ¶
type UnevaluatedItems Schema
UnevaluatedItems defines the unevaluatedItems JSON Schema keyword
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 ¶
type UnevaluatedProperties Schema
UnevaluatedProperties defines the unevaluatedProperties JSON Schema keyword
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 ¶
type UniqueItems bool
UniqueItems defines the uniqueItems JSON Schema keyword
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 ¶
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 }
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
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 ¶
type Void struct{}
Void is a placeholder definition for a keyword
func (*Void) Register ¶
func (vo *Void) Register(uri string, registry *SchemaRegistry)
Register 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 ¶
type WriteOnly bool
WriteOnly defines the writeOnly JSON Schema keyword
func (*WriteOnly) Register ¶
func (w *WriteOnly) Register(uri string, registry *SchemaRegistry)
Register 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