aicra/internal/checker/default/int/main.go

43 lines
836 B
Go
Raw Normal View History

package main
import (
"git.xdrm.io/go/aicra/driver"
"reflect"
)
func main() {}
func Export() driver.Checker { return new(IntChecker) }
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,
}
type IntChecker int
2018-07-08 23:34:21 +00:00
// Match matches the string 'int'
func (ick IntChecker) Match(name string) bool {
return name == "int"
}
2018-07-08 23:34:21 +00:00
// Check returns true for any type from the @validationTable
func (ick IntChecker) Check(value interface{}) bool {
kind := reflect.TypeOf(value).Kind()
_, isTypeValid := validationTable[kind]
return isTypeValid
}