func ValidateInt(data interface{}, key string, min, max int, def ...int) (int, error) {
	var defVal interface{}
	ldef := len(def)
	if ldef > 0 {
		defVal = def[0]
	}
	val, err := checkExist(data, key, defVal)
	if err != nil {
		return 0, err
	}
	switch val.(type) {
	case int:
		return val.(int), nil
	case string:
		value := val.(string)
		if !IsInt(value) {
			if ldef == 0 {
				return 0, errors.New(key + " must be an integer")
			}
			return def[0], nil
		}
		v, err := strconv.Atoi(value)
		if err != nil {
			if ldef == 0 {
				return 0, errors.New(key + " must be an integer")
			}
			return def[0], nil
		}
		if min != -1 && v < min {
			if ldef == 0 {
				return 0, errors.New(key + " is too small (minimum is " + strconv.Itoa(min) + ")")
			}
			return def[0], nil
		}
		if max != -1 && v > max {
			if ldef == 0 {
				return 0, errors.New(key + " is too big (maximum is " + strconv.Itoa(max) + ")")
			}
			return def[0], nil
		}
		return v, nil
	default:
		return 0, errors.New("type invalid, must be string or int")
	}
}
ValidateInt validate 32 bit integer
package vvalidator
import (
	"errors"
	"regexp"
	"strconv"
	"strings"
	"unicode/utf8"
)