2020-03-14 15:13:05 +00:00
|
|
|
package datatype
|
|
|
|
|
2020-03-28 17:48:27 +00:00
|
|
|
import "reflect"
|
|
|
|
|
2020-03-14 15:13:05 +00:00
|
|
|
// Validator returns whether a given value fulfills a datatype
|
|
|
|
// and casts the value into a compatible type
|
|
|
|
type Validator func(value interface{}) (cast interface{}, valid bool)
|
|
|
|
|
2020-03-22 15:50:10 +00:00
|
|
|
// T builds a T from the type definition (from the configuration field "type") and returns NIL if the type
|
|
|
|
// definition does not match this T ; the registry is passed for recursive datatypes (e.g. slices, structs, etc)
|
|
|
|
// to be able to access other datatypes
|
2020-03-16 08:20:00 +00:00
|
|
|
type T interface {
|
2020-03-28 18:11:23 +00:00
|
|
|
Type() reflect.Type
|
2020-03-22 15:50:10 +00:00
|
|
|
Build(typeDefinition string, registry ...T) Validator
|
2020-03-14 15:13:05 +00:00
|
|
|
}
|