2018-05-22 18:27:51 +00:00
|
|
|
package main
|
|
|
|
|
2018-05-28 16:25:17 +00:00
|
|
|
import (
|
2018-10-02 09:10:21 +00:00
|
|
|
"git.xdrm.io/go/aicra/driver"
|
2018-05-28 16:25:17 +00:00
|
|
|
"reflect"
|
|
|
|
)
|
|
|
|
|
2018-10-02 09:10:21 +00:00
|
|
|
func main() {}
|
|
|
|
func Export() driver.Checker { return new(IntChecker) }
|
|
|
|
|
2018-05-28 16:25:17 +00:00
|
|
|
var validationTable = map[reflect.Kind]interface{}{
|
|
|
|
reflect.Float32: nil,
|
|
|
|
reflect.Float64: nil,
|
|
|
|
reflect.Int: nil,
|
|
|
|
reflect.Int8: nil,
|
|
|
|
reflect.Int16: nil,
|
|
|
|
reflect.Int32: nil,
|
|
|
|
reflect.Int64: nil,
|
|
|
|
reflect.Uint: nil,
|
|
|
|
reflect.Uint8: nil,
|
|
|
|
reflect.Uint16: nil,
|
|
|
|
reflect.Uint32: nil,
|
|
|
|
reflect.Uint64: nil,
|
|
|
|
}
|
|
|
|
|
2018-10-02 09:10:21 +00:00
|
|
|
type IntChecker int
|
|
|
|
|
2018-07-08 23:34:21 +00:00
|
|
|
// Match matches the string 'int'
|
2018-10-02 09:10:21 +00:00
|
|
|
func (ick IntChecker) Match(name string) bool {
|
2018-05-22 18:27:51 +00:00
|
|
|
return name == "int"
|
|
|
|
}
|
|
|
|
|
2018-07-08 23:34:21 +00:00
|
|
|
// Check returns true for any type from the @validationTable
|
2018-10-02 09:10:21 +00:00
|
|
|
func (ick IntChecker) Check(value interface{}) bool {
|
2018-05-22 18:27:51 +00:00
|
|
|
|
2018-05-28 16:25:17 +00:00
|
|
|
kind := reflect.TypeOf(value).Kind()
|
|
|
|
|
|
|
|
_, isTypeValid := validationTable[kind]
|
|
|
|
|
|
|
|
return isTypeValid
|
|
|
|
|
2018-05-22 18:27:51 +00:00
|
|
|
}
|