Documentation ¶
Index ¶
- func AsGOJSONSchema(t Type) interface{}
- func AsJSONSchema(t Type) (string, error)
- func Doc(t Type) string
- func ValidateGO(t Type, document interface{}) *gutil.ErrorCollector
- type AnyType
- type BoolType
- type EnumType
- type IntType
- type ListType
- type MapType
- type NullType
- type ObjectAttribute
- type ObjectType
- type SomeOf
- type StringType
- type Type
- type TypeDefs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsGOJSONSchema ¶
func AsGOJSONSchema(t Type) interface{}
AsGOJSONSchema returns the validator as a map, slice, scalar composite defining the json schema
func AsJSONSchema ¶
AsJSONSchema returns the validator as a json schema string
func Doc ¶
Doc returns a string containing a very coarse documentation built from the validator definition
func ValidateGO ¶
func ValidateGO(t Type, document interface{}) *gutil.ErrorCollector
ValidateGO will validate the provided interface which can be a composite of maps, slices and scalars, restricted to constructs that are allowed in json (map keys must be strings, only float64, string, bool as scalars)
Types ¶
type AnyType ¶
type AnyType interface { Type }
AnyType can be just anything, map, list, null, scalar...
func NewAnyType ¶
type BoolType ¶
type BoolType interface { Type }
BoolType validates that the value is of type bool
func NewBoolType ¶
type EnumType ¶
EnumType validates that a given string is one of the provided values
func NewEnumType ¶
type MapType ¶
MapType validates that the element is a map/hash (key value pairs) key is always string, value can be defined
func NewMapType ¶
type NullType ¶
type NullType interface { Type }
NullType validates that the given value is nil/null
func NewNullType ¶
type ObjectAttribute ¶
type ObjectAttribute interface { TypeDefs }
ObjectAttribute validates one single attribute of an object
type ObjectType ¶
type ObjectType interface { Type Attribute(name string) ObjectAttribute Optional(name string) ObjectAttribute }
ObjectType validates that the element is an object with named attributes
func NewObjectType ¶
func NewObjectType(description string, each func(ObjectType)) ObjectType
type StringType ¶
type StringType interface { Type }
StringType validates that the value is a string
func NewStringType ¶
func NewStringType(description string) StringType
type Type ¶
type Type interface {
// contains filtered or unexported methods
}
Type is an interface that is implemented by all nodes of a validation tree
type TypeDefs ¶
type TypeDefs interface { String(desc string) StringType Int(desc string) IntType Bool(desc string) BoolType SomeOf(ops func(SomeOf)) SomeOf Enum(desc string) EnumType Null(desc string) NullType Any(desc string) AnyType Object(desc string, ops func(ObjectType)) ObjectType Map(ops func(MapType)) MapType List(ops func(ListType)) ListType }
TypeDefs provides methods to define a validator for a child of collection validators