types

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2020 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BooleanType = "bool"
	StringType  = "string"
	Float64Type = "float64"
	Float32Type = "float32"
	Int64Type   = "int64"
	IntType     = "int"
	Int32Type   = "int32"
	ByteType    = "byte"
)

Variables

This section is empty.

Functions

func FilterTag

func FilterTag(tagSub string, tags []string) ([]string, string)

Types

type Composit

type Composit int
const (
	Simple Composit = iota
	Enum
	Object
	Map
	Array
	File
)

type Element

type Element struct {
	Name       string
	Type       *Type
	Serialized string
}

type RegexValidator

type RegexValidator struct {
	Tag   string
	Regex string
}

type Type

type Type struct {
	Composit   Composit
	Name       string
	Type       string
	Validation string
	Nestable   bool
	Required   bool
	Elements   []Element
	Validator  *RegexValidator
}

func FromSchema

func FromSchema(name string, schema *spec.Schema, required bool, findSchemaFunc func(name string) *spec.Schema) (*Type, error)

func FromSimpleSchema

func FromSimpleSchema(name string, schema *spec.SimpleSchema, required bool, validations *spec.CommonValidations) (*Type, error)

func New

func New(composit Composit, name, typ string, required, nestable bool, tags ...string) *Type

func NewArray

func NewArray(name string, required bool, elementType *Type) *Type

func NewEnum

func NewEnum(name string, required bool, values []interface{}) (*Type, error)

func NewFile

func NewFile(name string, required bool) *Type

func NewMap

func NewMap(name string, required bool, elementType *Type) *Type

func NewObject

func NewObject(name string, required bool) *Type

func (*Type) AddElement

func (typ *Type) AddElement(name string, t *Type, serialized string)

func (*Type) GetValidators

func (typ *Type) GetValidators() []*RegexValidator

func (*Type) WriteTo

func (typ *Type) WriteTo(file *file.File) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL