Documentation ¶
Index ¶
- Variables
- func Bool(b bool) *bool_
- func Bools(bools ...bool) *slice
- func Float(f float64) *float_
- func Floats(floats ...float64) *slice
- func Int(i int64) *int_
- func Ints(ints ...int64) *slice
- func Map(givenmap interface{}) *map_
- func MapBools(m map[string]bool) *map_
- func MapFloats(m map[string]float64) *map_
- func MapInts(m map[string]int64) *map_
- func MapStrings(m map[string]string) *map_
- func MapTimes(m map[string]time.Time) *map_
- func MapType(typ string, vals ...interface{}) *map_
- func New(øprototype interface{}, ønewstruct interface{}) (ønew interface{})
- func Proto(østruct interface{}) (østru interface{})
- func Slice(typ string, intfs ...interface{}) *slice
- func String(s string) *string_
- func Strings(strings ...string) *slice
- func StructType(østruct interface{}) string
- func Time(t time.Time) *time_
- func Times(times ...time.Time) *slice
- func Validaters(vs ...Validater) func(f *Field) (errs []error)
- type Field
- func (øfieldSpec Field) Default() Type
- func (øfieldSpec Field) Enum() []Type
- func (øField *Field) Get() (i interface{})
- func (øField *Field) IsValid() bool
- func (øField *Field) MarshalJSON() ([]byte, error)
- func (øField *Field) MustScanAndValidate(s string)
- func (øField *Field) MustScanString(s string)
- func (øField *Field) MustSet(i interface{})
- func (øField *Field) MustValidate()
- func (øfieldSpec Field) Name() string
- func (øfieldSpec Field) New(østruct interface{}) *Field
- func (øfieldSpec Field) Path() string
- func (øField *Field) Scan(src interface{}) error
- func (øField *Field) ScanAndValidate(s string) (errs []error)
- func (øField *Field) ScanString(s string) error
- func (øField *Field) Set(i interface{}) error
- func (øField *Field) String() string
- func (øfieldSpec Field) StructType() string
- func (øField *Field) UnmarshalJSON(data []byte) (err error)
- func (øField *Field) Validate() (errs []error)
- func (øField *Field) Value() (v driver.Value, err error)
- type Type
- type Validater
- type ValidaterFunc
Constants ¶
This section is empty.
Variables ¶
var StringMustNotBeEmpty = ValidaterFunc(func(f *Field) (err error) { if f.String() == "" { return fmt.Errorf("must not be empty") } return })
Functions ¶
func MapStrings ¶
func MapType ¶
func MapType(typ string, vals ...interface{}) *map_
panics if there are different types
func New ¶
func New(øprototype interface{}, ønewstruct interface{}) (ønew interface{})
prefills the given newstruct based on the given prototype
func Proto ¶
func Proto(østruct interface{}) (østru interface{})
sets all attributes of a struct that are of type *Field to a *Field with the Type set to what is given in the tag "fat.type" with defaults set to what is given in the tag "fat.default" and with enums set to what is in the tag "fat.enum", separated by pipe symbols (|)
func Slice ¶
func Slice(typ string, intfs ...interface{}) *slice
panics if there are different types
func StructType ¶
func StructType(østruct interface{}) string
func Validaters ¶
Types ¶
type Field ¶
type Field struct { Type Struct interface{} // a reference to the struct IsSet bool // is true, if the value was set, i.e. the type was correct, it may however by invalid // saves the input for a failed scan, // is empty if the scan did not fail FailedScanInput string // contains filtered or unexported fields }
func (*Field) Get ¶
func (øField *Field) Get() (i interface{})
overwrite Type.Get to return default value, if IsSet is false
func (*Field) MarshalJSON ¶
func (*Field) MustScanAndValidate ¶
func (*Field) MustScanString ¶
calls Scan and panics if there is an error
func (*Field) MustSet ¶
func (øField *Field) MustSet(i interface{})
calls Set and panics if there is an error
func (*Field) ScanAndValidate ¶
func (*Field) ScanString ¶
overwrite Type.Scan to track, if the field was set field only is set if scan was successful Scan does not validation check, that must be run after Scan, or use ScanAndValidate
func (*Field) Set ¶
overwrite Type.Set to track, if the field was set field may be set and invalid at the same time IsSet only tells us, wether the type is correct
func (Field) StructType ¶
func (øfieldSpec Field) StructType() string
func (*Field) UnmarshalJSON ¶
type ValidaterFunc ¶
func (ValidaterFunc) Validate ¶
func (vf ValidaterFunc) Validate(f *Field) error