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-10-02 09:46:18 +00:00
|
|
|
"math"
|
2018-05-28 16:25:17 +00:00
|
|
|
)
|
|
|
|
|
2018-10-02 09:10:21 +00:00
|
|
|
func main() {}
|
|
|
|
func Export() driver.Checker { return new(IntChecker) }
|
|
|
|
|
|
|
|
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-10-02 09:46:18 +00:00
|
|
|
// check if float (default wrapping type)
|
|
|
|
floatVal, ok := value.(float64)
|
|
|
|
if !ok {
|
|
|
|
return false
|
|
|
|
}
|
2018-05-28 16:25:17 +00:00
|
|
|
|
2018-10-02 09:46:18 +00:00
|
|
|
// check if there is no floating point
|
|
|
|
return floatVal == math.Floor(floatVal)
|
2018-05-28 16:25:17 +00:00
|
|
|
|
2018-05-22 18:27:51 +00:00
|
|
|
}
|