Versions in this module Expand all Collapse all v0 v0.3.2 Nov 30, 2021 Changes in this version type SchemaSpec + func (spec SchemaSpec) Schema() (schema *Schema, result error) v0.3.1 Nov 23, 2021 v0.3.0 Nov 23, 2021 v0.2.3 Nov 23, 2021 Changes in this version + type ArrayField struct + func Array(name string, itemField Field) *ArrayField + func NewArray(spec ArrayFieldSpec, itemField Field, ...) *ArrayField + func (a *ArrayField) GetName() string + func (a *ArrayField) GetRequired() bool + func (a *ArrayField) GetType() string + func (a *ArrayField) MaxLength(length int) *ArrayField + func (a *ArrayField) MinLength(length int) *ArrayField + func (a *ArrayField) Required() *ArrayField + func (a *ArrayField) Validate(v interface{}) error + type ArrayFieldSpec struct + Items map[string]interface{} + MaxLength int + MinLength int + Name string + Required bool + type BooleanField struct + func Boolean(name string) *BooleanField + func NewBoolean(spec BooleanFieldSpec, valueValidation bool) *BooleanField + func (b *BooleanField) GetName() string + func (b *BooleanField) GetRequired() bool + func (b *BooleanField) GetType() string + func (b *BooleanField) Required() *BooleanField + func (b *BooleanField) ShouldBe(value bool) *BooleanField + func (b *BooleanField) Validate(v interface{}) error + type BooleanFieldSpec struct + Name string + Required bool + Value bool + type Field interface + GetName func() string + GetRequired func() bool + GetType func() string + Validate func(interface{}) error + type FloatField struct + func Float(name string) *FloatField + func NewFloat(spec FloatFieldSpec, ...) *FloatField + func (f *FloatField) GetName() string + func (f *FloatField) GetRequired() bool + func (f *FloatField) GetType() string + func (f *FloatField) Max(value float64) *FloatField + func (f *FloatField) Min(value float64) *FloatField + func (f *FloatField) Negative() *FloatField + func (f *FloatField) Positive() *FloatField + func (f *FloatField) Range(start, end float64) *FloatField + func (f *FloatField) Required() *FloatField + func (f *FloatField) Validate(v interface{}) error + type FloatFieldSpec struct + Max float64 + Min float64 + Name string + Positive bool + Ranges []FloatRangeSpec + Required bool + type FloatRangeSpec struct + End float64 + Start float64 + type IntRangeSpec struct + End int + Start int + type IntegerField struct + func Integer(name string) *IntegerField + func NewInteger(spec IntegerFieldSpec, ...) *IntegerField + func (i *IntegerField) GetName() string + func (i *IntegerField) GetRequired() bool + func (i *IntegerField) GetType() string + func (i *IntegerField) Max(value int) *IntegerField + func (i *IntegerField) Min(value int) *IntegerField + func (i *IntegerField) Negative() *IntegerField + func (i *IntegerField) Positive() *IntegerField + func (i *IntegerField) Range(start, end int) *IntegerField + func (i *IntegerField) Required() *IntegerField + func (i *IntegerField) Validate(v interface{}) error + type IntegerFieldSpec struct + Max int + Min int + Name string + Positive bool + Ranges []IntRangeSpec + Required bool + type NullField struct + func NewNull(spec NullFieldSpec) *NullField + func Null(name string) *NullField + func (n *NullField) GetName() string + func (n *NullField) GetRequired() bool + func (n *NullField) GetType() string + func (n *NullField) Validate(input interface{}) error + type NullFieldSpec struct + Name string + type ObjectField struct + func NewObject(spec ObjectFieldSpec, schema Schema) *ObjectField + func Object(name string, schema Schema) *ObjectField + func (o *ObjectField) GetName() string + func (o *ObjectField) GetRequired() bool + func (o *ObjectField) GetType() string + func (o *ObjectField) Required() *ObjectField + func (o *ObjectField) Validate(v interface{}) error + type ObjectFieldSpec struct + Name string + Required bool + Schema map[string]interface{} + type Schema struct + Fields []Field + func NewSchema(fields ...Field) Schema + func ReadFromBytes(input []byte) (*Schema, error) + func ReadFromFile(filePath string) (*Schema, error) + func ReadFromString(input string) (*Schema, error) + func (s *Schema) UnmarshalJSON(bytes []byte) error + func (s *Schema) ValidateBytes(input []byte) error + func (s *Schema) ValidateString(input string) error + type SchemaSpec struct + Fields []map[string]interface{} + type StringField struct + func NewString(spec StringFieldSpec, ...) *StringField + func String(name string) *StringField + func (s *StringField) Choices(choices ...string) *StringField + func (s *StringField) Format(format string) *StringField + func (s *StringField) GetName() string + func (s *StringField) GetRequired() bool + func (s *StringField) GetType() string + func (s *StringField) MaxLength(length int) *StringField + func (s *StringField) MinLength(length int) *StringField + func (s *StringField) Required() *StringField + func (s *StringField) Validate(value interface{}) error + type StringFieldSpec struct + Choices []string + Format string + MaxLength int + MinLength int + Name string + Required bool