2020-03-14 15:13:38 +00:00
|
|
|
package builtin
|
|
|
|
|
2020-03-28 17:48:27 +00:00
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
|
2021-06-20 19:29:46 +00:00
|
|
|
"github.com/xdrm-io/aicra/datatype"
|
2020-03-28 17:48:27 +00:00
|
|
|
)
|
2020-03-14 15:13:38 +00:00
|
|
|
|
|
|
|
// AnyDataType is what its name tells
|
|
|
|
type AnyDataType struct{}
|
|
|
|
|
2020-03-28 18:11:23 +00:00
|
|
|
// Type returns the type of data
|
|
|
|
func (AnyDataType) Type() reflect.Type {
|
|
|
|
return reflect.TypeOf(interface{}(nil))
|
2020-03-28 17:48:27 +00:00
|
|
|
}
|
|
|
|
|
2020-03-14 15:13:38 +00:00
|
|
|
// Build returns the validator
|
2020-03-22 15:50:10 +00:00
|
|
|
func (AnyDataType) Build(typeName string, registry ...datatype.T) datatype.Validator {
|
2020-03-14 15:13:38 +00:00
|
|
|
// nothing if type not handled
|
|
|
|
if typeName != "any" {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return func(value interface{}) (interface{}, bool) {
|
|
|
|
return value, true
|
|
|
|
}
|
|
|
|
}
|