Documentation
¶
Index ¶
Constants ¶
const TypeAny = Type("any")
TypeAny is the token used by JSON-Schema to designate that any kind of data
const TypeArray = Type("array")
TypeArray is the token used by JSON-Schema to designate that a schema describes an array.
const TypeBoolean = Type("boolean")
TypeBoolean is the token used by JSON-Schema to designate that a schema describes an boolean.
const TypeInteger = Type("integer")
TypeInteger is the token used by JSON-Schema to designate that a schema describes an integer.
const TypeNumber = Type("number")
TypeNumber is the token used by JSON-Schema to designate that a schema describes an number.
const TypeObject = Type("object")
TypeObject is the token used by JSON-Schema to designate that a schema describes an object.
const TypeString = Type("string")
TypeString is the token used by JSON-Schema to designate that a schema describes an string.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Any ¶ added in v0.4.0
type Any struct {
}
Any represents a any data type within a JSON-Schema.
func (Any) MarshalMap ¶ added in v0.5.0
MarshalMap populates object data into a map[string]interface{}
func (*Any) UnmarshalMap ¶ added in v0.5.0
UnmarshalMap tries to populate this object using data from a map[string]interface{}
type Array ¶
Array represents an array data type within a JSON-Schema.
func (Array) MarshalMap ¶ added in v0.5.0
MarshalMap populates object data into a map[string]interface{}
func (*Array) UnmarshalMap ¶ added in v0.3.0
UnmarshalMap tries to populate this object using data from a map[string]interface{}
type Boolean ¶
Boolean represents a boolean data type within a JSON-Schema.
func (*Boolean) MarshalMap ¶ added in v0.5.0
MarshalMap populates object data into a map[string]interface{}
func (*Boolean) UnmarshalMap ¶ added in v0.5.0
UnmarshalMap tries to populate this object using data from a map[string]interface{}
type Element ¶ added in v0.5.0
type Element interface {
// Type returns the Type of this particular schema element
Type() Type
// Validate checks an arbitrary data structure against the rules in the schema
Validate(interface{}) error
// Path traverses this schema to find child element that matches the provided path
Path(path.Path) (Element, error)
// MarshalMap populates the object data into a map[string]interface{}
MarshalMap() map[string]interface{}
}
Element interface wraps all of the methods required for schema elements.
func UnmarshalJSON ¶ added in v0.5.0
UnmarshalJSON tries to parse a []byte into a schema.Element
func UnmarshalMap ¶ added in v0.5.0
UnmarshalMap tries to parse a map[string]interface{} into a schema.Element
type Integer ¶
type Integer struct {
Required bool `json:"required"`
Default null.Int `json:"default"`
Minimum null.Int `json:"minimum"`
Maximum null.Int `json:"maximum"`
MultipleOf null.Int `json:"multipleOf"`
}
Integer represents an integer data type within a JSON-Schema.
func (Integer) MarshalMap ¶ added in v0.5.0
MarshalMap populates object data into a map[string]interface{}
func (*Integer) UnmarshalMap ¶ added in v0.5.0
UnmarshalMap tries to populate this object using data from a map[string]interface{}
type Number ¶
type Number struct {
Required bool `json:"required"`
Default null.Float `json:"default"`
Minimum null.Float `json:"minimum"`
Maximum null.Float `json:"maximum"`
}
Number represents a number data type within a JSON-Schema.
func (Number) MarshalMap ¶ added in v0.5.0
MarshalMap populates object data into a map[string]interface{}
func (*Number) UnmarshalMap ¶ added in v0.5.0
UnmarshalMap tries to populate this object using data from a map[string]interface{}
type Object ¶
Object represents an object data type within a JSON-Schema.
func (Object) MarshalMap ¶ added in v0.5.0
MarshalMap populates object data into a map[string]interface{}
func (*Object) UnmarshalMap ¶ added in v0.5.0
UnmarshalMap tries to populate this object using data from a map[string]interface{}
type Schema ¶
type Schema struct {
ID string `json:"$id"`
Comment string `json:"$comment"`
// contains filtered or unexported fields
}
Schema defines a (simplified) JSON-Schema object, that can be Marshalled/Unmarshalled to JSON.
func (Schema) UnmarshalJSON ¶ added in v0.5.0
UnmarshalJSON creates a new Schema object using a JSON-serialized byte array.
type String ¶
type String struct {
Required bool
Default string
MinLength null.Int
MaxLength null.Int
Pattern string
Format string
}
String represents a string data type within a JSON-Schema.
func (String) MarshalMap ¶ added in v0.5.0
MarshalMap populates object data into a map[string]interface{}
func (*String) UnmarshalMap ¶ added in v0.5.0
UnmarshalMap tries to populate this object using data from a map[string]interface{}
type StringFormat ¶ added in v0.3.0
StringFormat verifies that a string matches the desired format, and returns a non-nil error if it does not.
type Type ¶ added in v0.3.0
type Type string
Type enumerates all of the data types that can make up a schema