Documentation ¶
Overview ¶
The Model of MVC.
Index ¶
- Constants
- Variables
- func CopyFields(dst, src interface{}) (err error)
- func CopyFieldsIfNotEmpty(dst, src interface{}) (err error)
- func GenerateRandomPassword(length int) (string, error)
- func NormalizePhoneNumber(number string) string
- func ParseTagAttribs(tag string) map[string]string
- func PasswordHash(password string) string
- func SetAllSliceLengths(document interface{}, length int)
- func Visit(model interface{}, visitor Visitor) error
- func VisitMaxDepth(model interface{}, maxDepth int, visitor Visitor) error
- type Blob
- type Bool
- type Choice
- func (self *Choice) Get() string
- func (self *Choice) IsEmpty() bool
- func (self *Choice) Options(metaData *MetaData) []string
- func (self *Choice) Required(metaData *MetaData) bool
- func (self *Choice) Set(value string)
- func (self *Choice) SetString(str string) error
- func (self *Choice) String() string
- func (self *Choice) Validate(metaData *MetaData) error
- type Color
- func (self *Color) EqualsColor(c color.Color) bool
- func (self *Color) GetOrDefault(defaultColor string) string
- func (self *Color) IsEmpty() bool
- func (self *Color) IsValid() bool
- func (self *Color) RGBA() color.RGBA
- func (self *Color) Required(metaData *MetaData) bool
- func (self *Color) SetString(s string)
- func (self *Color) String() string
- func (self *Color) Validate(metaData *MetaData) error
- type Configuration
- type Country
- func (self *Country) EnglishName() string
- func (self *Country) FixValue(metaData *MetaData)
- func (self *Country) Get() string
- func (self *Country) IsEmpty() bool
- func (self *Country) Required(metaData *MetaData) bool
- func (self *Country) Set(value string) error
- func (self *Country) SetString(str string) error
- func (self *Country) String() string
- func (self *Country) Validate(metaData *MetaData) error
- type Date
- func (self *Date) FixValue(metaData *MetaData)
- func (self *Date) Format(format string) string
- func (self *Date) Get() string
- func (self *Date) IsEmpty() bool
- func (self *Date) Required(metaData *MetaData) bool
- func (self *Date) Set(value string) error
- func (self *Date) SetEmpty()
- func (self *Date) SetString(str string) error
- func (self *Date) SetTime(t time.Time)
- func (self *Date) SetTodayUTC()
- func (self *Date) SetUnixNanoseconds(nanos int64)
- func (self *Date) String() string
- func (self *Date) Time() time.Time
- func (self *Date) UnixNanoseconds() int64
- func (self *Date) Validate(metaData *MetaData) error
- type DateTime
- func (self *DateTime) FixValue(metaData *MetaData)
- func (self *DateTime) Format(format string) string
- func (self *DateTime) Get() string
- func (self *DateTime) IsEmpty() bool
- func (self *DateTime) Required(metaData *MetaData) bool
- func (self *DateTime) Set(value string) (err error)
- func (self *DateTime) SetEmpty()
- func (self *DateTime) SetNowUTC()
- func (self *DateTime) SetString(str string) error
- func (self *DateTime) SetTime(t time.Time)
- func (self *DateTime) SetUnixNanoseconds(nanos int64)
- func (self *DateTime) String() string
- func (self *DateTime) Time() time.Time
- func (self *DateTime) UnixNanoseconds() int64
- func (self *DateTime) Validate(metaData *MetaData) error
- type DynamicChoice
- func (self *DynamicChoice) CheckIndex(index int) error
- func (self *DynamicChoice) GetBSON() (interface{}, error)
- func (self *DynamicChoice) Index() int
- func (self *DynamicChoice) IsEmpty() bool
- func (self *DynamicChoice) Options() []string
- func (self *DynamicChoice) Required(metaData *MetaData) bool
- func (self *DynamicChoice) SetBSON(raw bson.Raw) (err error)
- func (self *DynamicChoice) SetIndex(index int) error
- func (self *DynamicChoice) SetOptions(options []string)
- func (self *DynamicChoice) SetString(str string) error
- func (self *DynamicChoice) String() string
- func (self *DynamicChoice) Validate(metaData *MetaData) error
- type DynamicValue
- type DynamicValues
- type Email
- func (self *Email) EqualsCaseinsensitive(address string) bool
- func (self *Email) FixValue(metaData *MetaData)
- func (self *Email) Get() string
- func (self *Email) IsEmpty() bool
- func (self *Email) Required(metaData *MetaData) bool
- func (self *Email) Set(value string) (err error)
- func (self *Email) SetString(str string) (err error)
- func (self *Email) String() string
- func (self *Email) Validate(metaData *MetaData) error
- type EmptyIterator
- type ErrorOnlyIterator
- type FieldOnlyVisitor
- func (self FieldOnlyVisitor) BeginIndexedFields(*MetaData) error
- func (self FieldOnlyVisitor) BeginNamedFields(*MetaData) error
- func (self FieldOnlyVisitor) EndIndexedFields(*MetaData) error
- func (self FieldOnlyVisitor) EndNamedFields(*MetaData) error
- func (self FieldOnlyVisitor) IndexedField(field *MetaData) error
- func (self FieldOnlyVisitor) NamedField(field *MetaData) error
- type File
- type FilterFunc
- type FilterIterator
- type Float
- func (self *Float) Get() float64
- func (self *Float) IsEmpty() bool
- func (self *Float) IsValid() bool
- func (self *Float) Max(metaData *MetaData) (max float64, ok bool, err error)
- func (self *Float) Min(metaData *MetaData) (min float64, ok bool, err error)
- func (self *Float) Required(metaData *MetaData) bool
- func (self *Float) Set(value float64)
- func (self *Float) SetString(str string) error
- func (self *Float) String() string
- func (self *Float) Valid(metaData *MetaData) bool
- func (self *Float) Validate(metaData *MetaData) error
- type FloatAboveMax
- type FloatBelowMin
- type FloatNotReal
- type GeoLocation
- type IndexedSliceIterator
- type Int
- func (self *Int) Get() int64
- func (self *Int) GetInt() int
- func (self *Int) IsEmpty() bool
- func (self *Int) Max(metaData *MetaData) (max int64, ok bool, err error)
- func (self *Int) Min(metaData *MetaData) (min int64, ok bool, err error)
- func (self *Int) Required(metaData *MetaData) bool
- func (self *Int) Set(value int64)
- func (self *Int) SetInt(value int)
- func (self *Int) SetString(str string) error
- func (self *Int) String() string
- func (self *Int) Validate(metaData *MetaData) error
- type IntAboveMax
- type IntBelowMin
- type InvalidChoice
- type InvalidCountryCode
- type InvalidLanguageCode
- type Iterator
- type IteratorFunc
- type Language
- func (self *Language) EnglishName() string
- func (self *Language) FixValue(metaData *MetaData)
- func (self *Language) Get() string
- func (self *Language) IsEmpty() bool
- func (self *Language) Required(metaData *MetaData) bool
- func (self *Language) Set(value string) error
- func (self *Language) SetString(str string) error
- func (self *Language) String() string
- func (self *Language) Validate(metaData *MetaData) error
- type LimitedIterator
- type MetaData
- func (self *MetaData) Attrib(tagKey, name string) (value string, ok bool)
- func (self *MetaData) BoolAttrib(tagKey, name string) bool
- func (self *MetaData) IsIndexedValue() bool
- func (self *MetaData) IsModelValue() bool
- func (self *MetaData) IsModelValueOrChild() bool
- func (self *MetaData) IsNamed() bool
- func (self *MetaData) IsNamedValue() bool
- func (self *MetaData) IsSelfOrParentIndexed() bool
- func (self *MetaData) ModelValidator() (val Validator, ok bool)
- func (self *MetaData) ModelValue() (val Value, ok bool)
- func (self *MetaData) NameOrIndex() string
- func (self *MetaData) NameOrWildcard() string
- func (self *MetaData) Path() []*MetaData
- func (self *MetaData) RootParent() *MetaData
- func (self *MetaData) Selector() string
- func (self *MetaData) SelectorsMatch(list []string) bool
- func (self *MetaData) String() string
- func (self *MetaData) WildcardSelector() string
- type MetaDataKind
- type MultipleChoice
- func (self *MultipleChoice) Get() []string
- func (self *MultipleChoice) IsEmpty() bool
- func (self *MultipleChoice) IsSet(option string) bool
- func (self *MultipleChoice) Options(metaData *MetaData) []string
- func (self *MultipleChoice) Required(metaData *MetaData) bool
- func (self *MultipleChoice) Set(value ...string)
- func (self *MultipleChoice) SetString(str string) error
- func (self *MultipleChoice) String() string
- func (self *MultipleChoice) Validate(metaData *MetaData) error
- type Password
- func (self *Password) EqualsHashed(value string) bool
- func (self *Password) FixValue(metaData *MetaData)
- func (self *Password) Get() string
- func (self *Password) IsEmpty() bool
- func (self *Password) Maxlen(metaData *MetaData) (maxlen int, ok bool, err error)
- func (self *Password) Minlen(metaData *MetaData) (minlen int, ok bool, err error)
- func (self *Password) Required(metaData *MetaData) bool
- func (self *Password) Set(value string)
- func (self *Password) SetHashed(value string)
- func (self *Password) SetString(str string) error
- func (self *Password) String() string
- func (self *Password) Validate(metaData *MetaData) error
- type Phone
- func (self *Phone) FixValue(metaData *MetaData)
- func (self *Phone) Get() string
- func (self *Phone) IsEmpty() bool
- func (self *Phone) Required(metaData *MetaData) bool
- func (self *Phone) Set(value string)
- func (self *Phone) SetString(str string) error
- func (self *Phone) String() string
- func (self *Phone) Validate(metaData *MetaData) error
- type RandomIterator
- type Ref
- type Reference
- type RequiredError
- type RichText
- func (self *RichText) FixValue(metaData *MetaData)
- func (self *RichText) Get() string
- func (self *RichText) GetOrDefault(defaultText string) string
- func (self *RichText) IsEmpty() bool
- func (self *RichText) Maxlen(metaData *MetaData) (maxlen int, ok bool, err error)
- func (self *RichText) Minlen(metaData *MetaData) (minlen int, ok bool, err error)
- func (self *RichText) Required(metaData *MetaData) bool
- func (self *RichText) Set(value string)
- func (self *RichText) SetString(str string) error
- func (self *RichText) String() string
- func (self *RichText) Validate(metaData *MetaData) error
- type SingletonIterator
- type SliceIterator
- type Slug
- func (self *Slug) FixValue(metaData *MetaData)
- func (self *Slug) Get() string
- func (self *Slug) GetOrDefault(defaultSlug string) string
- func (self *Slug) IsEmpty() bool
- func (self *Slug) Maxlen(metaData *MetaData) (maxlen int, ok bool, err error)
- func (self *Slug) Minlen(metaData *MetaData) (minlen int, ok bool, err error)
- func (self *Slug) Required(metaData *MetaData) bool
- func (self *Slug) Set(value string)
- func (self *Slug) SetSlug(str string) error
- func (self *Slug) String() string
- func (self *Slug) Validate(metaData *MetaData) error
- type SlugTooLong
- type SlugTooShort
- type SortIterator
- type String
- func (self *String) FixValue(metaData *MetaData)
- func (self *String) Get() string
- func (self *String) GetOrDefault(defaultString string) string
- func (self *String) IsEmpty() bool
- func (self *String) Maxlen(metaData *MetaData) (maxlen int, ok bool, err error)
- func (self *String) Minlen(metaData *MetaData) (minlen int, ok bool, err error)
- func (self *String) Required(metaData *MetaData) bool
- func (self *String) Set(value string)
- func (self *String) SetString(str string) error
- func (self *String) String() string
- func (self *String) Validate(metaData *MetaData) error
- type StringTooLong
- type StringTooShort
- type Text
- func (self *Text) FixValue(metaData *MetaData)
- func (self *Text) Get() string
- func (self *Text) GetOrDefault(defaultText string) string
- func (self *Text) IsEmpty() bool
- func (self *Text) Maxlen(metaData *MetaData) (maxlen int, ok bool, err error)
- func (self *Text) Minlen(metaData *MetaData) (minlen int, ok bool, err error)
- func (self *Text) Required(metaData *MetaData) bool
- func (self *Text) Set(value string)
- func (self *Text) SetString(str string) error
- func (self *Text) String() string
- func (self *Text) Validate(metaData *MetaData) error
- type Time
- type Url
- func (self *Url) FixValue(metaData *MetaData)
- func (self *Url) Get() string
- func (self *Url) GetOrDefault(defaultURL string) string
- func (self *Url) IsEmpty() bool
- func (self *Url) Required(metaData *MetaData) bool
- func (self *Url) Set(value string) error
- func (self *Url) SetDataUrl(value string) error
- func (self *Url) SetString(str string) error
- func (self *Url) String() string
- func (self *Url) Validate(metaData *MetaData) error
- type Validator
- type Value
- type Visitor
- type VisitorFunc
- func (self VisitorFunc) BeginIndexedFields(indexedFields *MetaData) error
- func (self VisitorFunc) BeginNamedFields(namedFields *MetaData) error
- func (self VisitorFunc) EndIndexedFields(indexedFields *MetaData) error
- func (self VisitorFunc) EndNamedFields(namedFields *MetaData) error
- func (self VisitorFunc) IndexedField(field *MetaData) error
- func (self VisitorFunc) NamedField(field *MetaData) error
Constants ¶
const DateFormat = "2006-01-02"
const DateTimeFormat = "2006-01-02 15:04:05"
const ShortDateTimeFormat = "2006-01-02 15:04"
Variables ¶
var DynamicValueType = reflect.TypeOf(DynamicValue{})
var StructTagKey = "model"
Functions ¶
func CopyFields ¶
func CopyFields(dst, src interface{}) (err error)
CopyFields copies matching struct/array/slice fields that implement the Value interface from src to dst. Matching is done by comparing the MetaData.Selector() of the fields. Copying is done by calling SetString() of dst with the result from String() of src. This way even not exactly matching models can be copied by converting to and from strings if this is possible without errors.
func CopyFieldsIfNotEmpty ¶
func CopyFieldsIfNotEmpty(dst, src interface{}) (err error)
CopyFieldsIfNotEmpty copies matching struct/array/slice fields that implement the Value interface from src to dst, if IsEmpty() of src returns false. Matching is done by comparing the MetaData.Selector() of the fields. Copying is done by calling SetString() of dst with the result from String() of src. This way even not exactly matching models can be copied by converting to and from strings if this is possible without errors.
func GenerateRandomPassword ¶
func NormalizePhoneNumber ¶
func ParseTagAttribs ¶
func PasswordHash ¶
func SetAllSliceLengths ¶
func SetAllSliceLengths(document interface{}, length int)
SetAllSliceLengths sets the length of all slices in document.
func VisitMaxDepth ¶
Types ¶
type Blob ¶
type Blob []byte
Blob is just a bunch of bytes. Struct tag attributes:
`model:"required"`
type Choice ¶
type Choice string
Choice can hold one of several string options. The options are defined by the struct tag attribute "options" delimited by colons ",". A colon in an option can be escaped with "\," An empty string can be used as the first option. Choice is required, when the first option in not an empty string. Struct tag attributes:
`model:"options=Red,Green,Blue"` `model:"options=,Second,Third"` // empty string is a valid value
type Color ¶
type Color string
Color holds a hex web-color with the # prefix. The Set method accepts all valid web color syntaxes except for color names. Struct tag attributes:
`model:"required"`
func (*Color) GetOrDefault ¶
type Configuration ¶
type Configuration struct {
Debug bool
}
var Config Configuration
func (*Configuration) Close ¶
func (self *Configuration) Close() error
func (*Configuration) Init ¶
func (self *Configuration) Init() error
func (*Configuration) Name ¶
func (self *Configuration) Name() string
type Date ¶
type Date string
func (*Date) SetTodayUTC ¶
func (self *Date) SetTodayUTC()
func (*Date) SetUnixNanoseconds ¶
func (*Date) UnixNanoseconds ¶
type DateTime ¶
type DateTime string
DateTime
func NewDateTime ¶
func (*DateTime) SetUnixNanoseconds ¶
func (*DateTime) UnixNanoseconds ¶
type DynamicChoice ¶
type DynamicChoice struct {
// contains filtered or unexported fields
}
func (*DynamicChoice) CheckIndex ¶
func (self *DynamicChoice) CheckIndex(index int) error
func (*DynamicChoice) GetBSON ¶
func (self *DynamicChoice) GetBSON() (interface{}, error)
func (*DynamicChoice) Index ¶
func (self *DynamicChoice) Index() int
func (*DynamicChoice) IsEmpty ¶
func (self *DynamicChoice) IsEmpty() bool
func (*DynamicChoice) Options ¶
func (self *DynamicChoice) Options() []string
func (*DynamicChoice) Required ¶
func (self *DynamicChoice) Required(metaData *MetaData) bool
func (*DynamicChoice) SetIndex ¶
func (self *DynamicChoice) SetIndex(index int) error
func (*DynamicChoice) SetOptions ¶
func (self *DynamicChoice) SetOptions(options []string)
func (*DynamicChoice) SetString ¶
func (self *DynamicChoice) SetString(str string) error
func (*DynamicChoice) String ¶
func (self *DynamicChoice) String() string
func (*DynamicChoice) Validate ¶
func (self *DynamicChoice) Validate(metaData *MetaData) error
type DynamicValue ¶
DynamicValue can be used to build a model dynamically instead of using a static typed struct. See DynamicValues
func (*DynamicValue) Attrib ¶
func (self *DynamicValue) Attrib(tagKey, name string) string
func (*DynamicValue) GetBSON ¶
func (self *DynamicValue) GetBSON() (interface{}, error)
func (*DynamicValue) SetAttrib ¶
func (self *DynamicValue) SetAttrib(tagKey, name, value string)
type DynamicValues ¶
type DynamicValues []DynamicValue
DynamicValues is used to create a model dynamically instead of using a static typed struct.
func (DynamicValues) Get ¶
func (self DynamicValues) Get(name string) (value *DynamicValue, found bool)
type EmptyIterator ¶
type EmptyIterator struct { }
func (*EmptyIterator) Err ¶
func (self *EmptyIterator) Err() error
func (*EmptyIterator) Next ¶
func (self *EmptyIterator) Next(resultRef interface{}) bool
type ErrorOnlyIterator ¶
type ErrorOnlyIterator struct {
// contains filtered or unexported fields
}
func (*ErrorOnlyIterator) Err ¶
func (self *ErrorOnlyIterator) Err() error
func (*ErrorOnlyIterator) Next ¶
func (self *ErrorOnlyIterator) Next(resultRef interface{}) bool
type FieldOnlyVisitor ¶
FieldOnlyVisitor calls its function for every struct, array and slice field.
func (FieldOnlyVisitor) BeginIndexedFields ¶
func (self FieldOnlyVisitor) BeginIndexedFields(*MetaData) error
func (FieldOnlyVisitor) BeginNamedFields ¶
func (self FieldOnlyVisitor) BeginNamedFields(*MetaData) error
func (FieldOnlyVisitor) EndIndexedFields ¶
func (self FieldOnlyVisitor) EndIndexedFields(*MetaData) error
func (FieldOnlyVisitor) EndNamedFields ¶
func (self FieldOnlyVisitor) EndNamedFields(*MetaData) error
func (FieldOnlyVisitor) IndexedField ¶
func (self FieldOnlyVisitor) IndexedField(field *MetaData) error
func (FieldOnlyVisitor) NamedField ¶
func (self FieldOnlyVisitor) NamedField(field *MetaData) error
type FilterFunc ¶
type FilterFunc func(resultRef interface{}) bool
type FilterIterator ¶
type FilterIterator struct { Iterator PassFilter FilterFunc }
func (*FilterIterator) Next ¶
func (self *FilterIterator) Next(resultRef interface{}) bool
type FloatAboveMax ¶
func (*FloatAboveMax) Error ¶
func (self *FloatAboveMax) Error() string
type FloatBelowMin ¶
func (*FloatBelowMin) Error ¶
func (self *FloatBelowMin) Error() string
type FloatNotReal ¶
type FloatNotReal struct {
Value float64
}
func (*FloatNotReal) Error ¶
func (self *FloatNotReal) Error() string
type GeoLocation ¶
func (*GeoLocation) IsEmpty ¶
func (self *GeoLocation) IsEmpty() bool
func (*GeoLocation) Required ¶
func (self *GeoLocation) Required(metaData *MetaData) bool
func (*GeoLocation) SetString ¶
func (self *GeoLocation) SetString(str string) error
func (*GeoLocation) String ¶
func (self *GeoLocation) String() string
func (*GeoLocation) Validate ¶
func (self *GeoLocation) Validate(metaData *MetaData) error
type IndexedSliceIterator ¶
type IndexedSliceIterator struct {
// contains filtered or unexported fields
}
func NewIndexedSliceIterator ¶
func NewIndexedSliceIterator(slice interface{}, indices []int) *IndexedSliceIterator
func (*IndexedSliceIterator) Err ¶
func (self *IndexedSliceIterator) Err() error
func (*IndexedSliceIterator) Next ¶
func (self *IndexedSliceIterator) Next(resultRef interface{}) bool
type IntAboveMax ¶
func (*IntAboveMax) Error ¶
func (self *IntAboveMax) Error() string
type IntBelowMin ¶
func (*IntBelowMin) Error ¶
func (self *IntBelowMin) Error() string
type InvalidChoice ¶
func (*InvalidChoice) Error ¶
func (self *InvalidChoice) Error() string
type InvalidCountryCode ¶
type InvalidCountryCode struct {
CountryCode string
}
func (*InvalidCountryCode) String ¶
func (self *InvalidCountryCode) String() string
type InvalidLanguageCode ¶
type InvalidLanguageCode struct {
Language string
}
func (*InvalidLanguageCode) String ¶
func (self *InvalidLanguageCode) String() string
type Iterator ¶
type Iterator interface { // Next tries to unmarshalles the next iteration's data into resultRef // and returns a bool indicating if it was successful. // After Next() has returned false, check the result of Err(). Next(resultRef interface{}) bool // Err returns the error of the last iteration. // Err returns nil if the last iteration was successful, // or there was no last iteration. Err() error }
Iteration stops with Next() == nil, check Err() afterwards.
Be careful when using the address of a local variable for resultRef in a loop that creates a closure function that will be called later for rendering. Go does not make copies of variables that are bound to closure, but references them. If a closure is called outside of the loop, it will always reference the same variable with the value from the last Next() call in it.
func ConversionIterator ¶
func ConversionIterator(from Iterator, fromResultPtr interface{}, conversionFunc func(interface{}) interface{}) Iterator
ConvertIterator returns an Iterator that calls conversionFunc for every from.Next() result and returns the result of conversionFunc at every Next().
func NewErrorOnlyIterator ¶
type IteratorFunc ¶
type IteratorFunc func() interface{}
func (IteratorFunc) Err ¶
func (self IteratorFunc) Err() error
func (IteratorFunc) Next ¶
func (self IteratorFunc) Next() interface{}
type Language ¶
type Language string
Attributes:
label required
func NewLanguage ¶
func (*Language) EnglishName ¶
type LimitedIterator ¶
type LimitedIterator struct { Iterator // contains filtered or unexported fields }
func NewLimitedIterator ¶
func NewLimitedIterator(iter Iterator, limit int) *LimitedIterator
func (*LimitedIterator) Next ¶
func (self *LimitedIterator) Next(resultRef interface{}) bool
type MetaData ¶
type MetaData struct { Kind MetaDataKind Value reflect.Value Depth int // number of steps up to the root parent Name string // empty for array and slice fields Index int // will also be set for struct fields Parent *MetaData Dynamic bool // contains filtered or unexported fields }
MetaData holds meta data about an model data item.
func (*MetaData) Attrib ¶
Attrib returns the value of a tag attribute if available. Array and slice fields inherit the attributes of their named parent fields. The meaning of attributes is interpreted by the package that reads them. Attributes are defined in a struct tag named "gostart", "model" or "view" and written as name=value. Multiple attributes are separated by '|'. Example:
type Struct { X int `model:"min=0|max=10"` S []int `model:"maxlen=3|min=0|max=10" hidden int Ignore int `gostart:"-"` Z int `view:"lable=A longer label for display"` }
func (*MetaData) BoolAttrib ¶
BoolAttrib uses Attrib() to check if the value of an attribute is "true". A non existing attribibute is considered to be false.
func (*MetaData) IsIndexedValue ¶
func (*MetaData) IsModelValue ¶
func (*MetaData) IsModelValueOrChild ¶
func (*MetaData) IsNamedValue ¶
func (*MetaData) IsSelfOrParentIndexed ¶
func (*MetaData) ModelValidator ¶
func (*MetaData) ModelValue ¶
func (*MetaData) NameOrIndex ¶
NameOrIndex returns self.Name if not empty or else self.Index.
func (*MetaData) NameOrWildcard ¶
NameOrWildcard returns self.Name if not empty or else the wildcard "$".
func (*MetaData) Path ¶
Path returns a slice of *MetaData that holds all parents from the root parent up to (and including) self.
func (*MetaData) RootParent ¶
func (*MetaData) Selector ¶
Selector returns the field names or indices for array/slice fields from the root parent up the the current data item concatenated with with '.'.
func (*MetaData) SelectorsMatch ¶
func (*MetaData) WildcardSelector ¶
WildcardSelector returns the field names or the wildcard '$' for array/slice fields from the root parent up the the current data item concatenated with with '.'.
type MetaDataKind ¶
type MetaDataKind int
MetaDataKind is the kind of a data item described by MetaData.
const ( StructKind MetaDataKind = iota MapKind DynamicKind ArrayKind SliceKind ValueKind // everything else, no children )
func GetMetaDataKind ¶
func GetMetaDataKind(v reflect.Value) MetaDataKind
func (MetaDataKind) HasIndexedFields ¶
func (self MetaDataKind) HasIndexedFields() bool
func (MetaDataKind) HasNamedFields ¶
func (self MetaDataKind) HasNamedFields() bool
func (MetaDataKind) String ¶
func (self MetaDataKind) String() string
type MultipleChoice ¶
type MultipleChoice []string
func (*MultipleChoice) Get ¶
func (self *MultipleChoice) Get() []string
func (*MultipleChoice) IsEmpty ¶
func (self *MultipleChoice) IsEmpty() bool
func (*MultipleChoice) IsSet ¶
func (self *MultipleChoice) IsSet(option string) bool
func (*MultipleChoice) Options ¶
func (self *MultipleChoice) Options(metaData *MetaData) []string
func (*MultipleChoice) Required ¶
func (self *MultipleChoice) Required(metaData *MetaData) bool
func (*MultipleChoice) Set ¶
func (self *MultipleChoice) Set(value ...string)
func (*MultipleChoice) SetString ¶
func (self *MultipleChoice) SetString(str string) error
func (*MultipleChoice) String ¶
func (self *MultipleChoice) String() string
func (*MultipleChoice) Validate ¶
func (self *MultipleChoice) Validate(metaData *MetaData) error
type Password ¶
type Password string
func NewPassword ¶
func (*Password) EqualsHashed ¶
type RandomIterator ¶
type RandomIterator struct { Iterator // contains filtered or unexported fields }
RandomIterator stores all values from Iterator in a slice and iterates them in random order. LessFunc will always be called with a pointer to the struct if Next is called with a pointer to a struct or the address of a pointer to a stract. For all other types LessFunc will be called with the type that that the argument of Next points to.
func NewRandomIterator ¶
func NewRandomIterator(iterator Iterator) *RandomIterator
func (*RandomIterator) Next ¶
func (self *RandomIterator) Next(resultRef interface{}) bool
type Ref ¶
type Ref string
type RequiredError ¶
type RequiredError struct {
// contains filtered or unexported fields
}
func NewRequiredError ¶
func NewRequiredError(metaData *MetaData) *RequiredError
func (RequiredError) Error ¶
func (self RequiredError) Error() string
type RichText ¶
type RichText string
func NewRichText ¶
func (*RichText) GetOrDefault ¶
type SingletonIterator ¶
type SingletonIterator struct { Singleton interface{} // contains filtered or unexported fields }
func NewSingletonIterator ¶
func NewSingletonIterator(singleton interface{}) *SingletonIterator
func (*SingletonIterator) Err ¶
func (self *SingletonIterator) Err() error
func (*SingletonIterator) Next ¶
func (self *SingletonIterator) Next(resultRef interface{}) bool
type SliceIterator ¶
type SliceIterator struct {
// contains filtered or unexported fields
}
SliceIterator
func NewSliceIterator ¶
func NewSliceIterator(slice interface{}) *SliceIterator
func (*SliceIterator) Err ¶
func (self *SliceIterator) Err() error
func (*SliceIterator) Next ¶
func (self *SliceIterator) Next(resultRef interface{}) bool
type SlugTooLong ¶
func (*SlugTooLong) Error ¶
func (self *SlugTooLong) Error() string
type SlugTooShort ¶
func (*SlugTooShort) Error ¶
func (self *SlugTooShort) Error() string
type SortIterator ¶
type SortIterator struct { Iterator Iterator CompareFunc interface{} // contains filtered or unexported fields }
func NewSortIterator ¶
func NewSortIterator(iterator Iterator, compareFunc interface{}) *SortIterator
func (*SortIterator) Err ¶
func (self *SortIterator) Err() error
func (*SortIterator) Next ¶
func (self *SortIterator) Next(resultRef interface{}) bool
type String ¶
type String string
func (*String) GetOrDefault ¶
type StringTooLong ¶
func (*StringTooLong) Error ¶
func (self *StringTooLong) Error() string
type StringTooShort ¶
func (*StringTooShort) Error ¶
func (self *StringTooShort) Error() string
type Time ¶
type Time int64
Time in milliseconds since January 1, year 1 00:00:00 UTC. Time values are always in UTC.
type Visitor ¶
type Visitor interface { BeginNamedFields(namedFields *MetaData) error NamedField(field *MetaData) error EndNamedFields(namedFields *MetaData) error BeginIndexedFields(indexedFields *MetaData) error IndexedField(field *MetaData) error EndIndexedFields(indexedFields *MetaData) error }
func FieldTypeVisitor ¶
func FieldTypeVisitor(callback interface{}) Visitor
FieldTypeVisitor calls callback for every struct field whose type is asignable to the type of the callback's first argument. callback can have a second, optional argument of type *MetaData. callback can return one error value or no result.
type VisitorFunc ¶
VisitorFunc calls its function for every Visitor method call, thus mapping all Visitor methods on a single function.
func (VisitorFunc) BeginIndexedFields ¶
func (self VisitorFunc) BeginIndexedFields(indexedFields *MetaData) error
func (VisitorFunc) BeginNamedFields ¶
func (self VisitorFunc) BeginNamedFields(namedFields *MetaData) error
func (VisitorFunc) EndIndexedFields ¶
func (self VisitorFunc) EndIndexedFields(indexedFields *MetaData) error
func (VisitorFunc) EndNamedFields ¶
func (self VisitorFunc) EndNamedFields(namedFields *MetaData) error
func (VisitorFunc) IndexedField ¶
func (self VisitorFunc) IndexedField(field *MetaData) error
func (VisitorFunc) NamedField ¶
func (self VisitorFunc) NamedField(field *MetaData) error
Source Files ¶
- blob.go
- bool.go
- choice.go
- color.go
- config.go
- conversioniterator.go
- country.go
- date.go
- datetime.go
- doc.go
- dynamicchoice.go
- dynamicvalue.go
- email.go
- emptyiterator.go
- erroronlyiterator.go
- errors.go
- fieldvisitors.go
- file.go
- filteriterator.go
- float.go
- functions.go
- geolocation.go
- indexedsliceiterator.go
- int.go
- iterator.go
- iteratorfunc.go
- language.go
- limitediterator.go
- metadata.go
- multiplechoice.go
- password.go
- phone.go
- randomiterator.go
- ref.go
- reference.go
- richtext.go
- singletoniterator.go
- sliceiterator.go
- slug.go
- sortiterator.go
- string.go
- text.go
- time.go
- url.go
- validator.go
- value.go
- visitor.go
- visitorfunc.go