func (s *StringValidator) IsValidFilePathWithRelativePath(str string) bool {
	ret := checkAllowRelativePath.MatchString(str)
	return !ret
}
IsValidFilePathWithRelativePath is Validates whether the value is a valid FilePath (allow with relative path)
package strutils
import (
	"errors"
	"html"
	"net"
	"net/url"
	"regexp"
	"strconv"
	"strings"
)
var emailPattern = regexp.MustCompile("^[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[a-zA-Z0-9](?:[\\w-]*[\\w])?$")
var domainPattern = regexp.MustCompile(`^(([a-zA-Z0-9-\p{L}]{1,63}\.)?(xn--)?[a-zA-Z0-9\p{L}]+(-[a-zA-Z0-9\p{L}]+)*\.)+[a-zA-Z\p{L}]{2,63}$`)
var urlPattern = regexp.MustCompile(`^((((https?|ftps?|gopher|telnet|nntp): 
type StringValidator struct{}
func NewStringValidator() *StringValidator {
	return &StringValidator{}
}
func (s *StringValidator) IsValidEmail(str string) bool {
	return emailPattern.MatchString(str)
}
func (s *StringValidator) IsValidDomain(str string) bool {
	return domainPattern.MatchString(str)
}
func (s *StringValidator) IsValidURL(str string) bool {
	return urlPattern.MatchString(str)
}
func (s *StringValidator) IsValidMACAddr(str string) bool {
	if _, err := net.ParseMAC(str); err == nil {
		return true
	}
	return false
}
const (
	none               = 0
	IPAny              = 1
	IPv4               = 32
	IPv6               = 39
	IPv4MappedIPv6     = 45
	IPv4CIDR           = IPv4 + 3
	IPv6CIDR           = IPv6 + 3
	IPv4MappedIPv6CIDR = IPv4MappedIPv6 + 3
)
func (s *StringValidator) IsValidIPAddr(str string, cktypes ...int) (bool, error) {
	for _, cktype := range cktypes {
		if cktype != IPAny && cktype != IPv4 && cktype != IPv6 && cktype != IPv4MappedIPv6 && cktype != IPv4CIDR && cktype != IPv6CIDR && cktype != IPv4MappedIPv6CIDR {
			return false, errors.New("Invalid Options")
		}
	}
	l := len(str)
	ret := getIPType(str, l)
	for _, ck := range cktypes {
		if ret != none && (ck == ret || ck == IPAny) {
			switch ret {
			case IPv4, IPv6, IPv4MappedIPv6:
				ip := net.ParseIP(str)
				if ip != nil {
					return true, nil
				}
			case IPv4CIDR, IPv6CIDR, IPv4MappedIPv6CIDR:
				_, _, err := net.ParseCIDR(str)
				if err == nil {
					return true, nil
				}
			}
		}
	}
	return false, errors.New("Invalid IPAddr")
}
func isCIDR(str string, l int) bool {
	if str[l-3] == '/' || str[l-2] == '/' {
		cidrBit := strings.Split(str, "/")
		if 2 == len(cidrBit) {
			bit, err := strconv.Atoi(cidrBit[1])
			if err == nil && bit >= 0 && bit <= 128 {
				return true
			}
		}
	}
	return false
}
func getIPType(str string, l int) int {
	if l < 3 {  
		return none
	}
	hasDot := strings.Index(str[2:], ".")
	hasColon := strings.Index(str[2:], ":")
	switch {
	case hasDot > -1 && hasColon == -1 && l >= 7 && l <= IPv4CIDR:
		if isCIDR(str, l) {
			return IPv4CIDR
		}
		return IPv4
	case hasDot == -1 && hasColon > -1 && l >= 6 && l <= IPv6CIDR:
		if isCIDR(str, l) {
			return IPv6CIDR
		}
		return IPv6
	case hasDot > -1 && hasColon > -1 && l >= 14 && l <= IPv4MappedIPv6:
		if isCIDR(str, l) {
			return IPv4MappedIPv6CIDR
		}
		return IPv4MappedIPv6
	}
	return none
}
const regexDenyFileNameCharList = `[\x00-\x1f|\x21-\x2c|\x3b-\x40|\x5b-\x5e|\x60|\x7b-\x7f]+`
const regexDenyFileName = `|\x2e\x2e\x2f+`
var checkAllowRelativePath = regexp.MustCompile(`(?m)(` + regexDenyFileNameCharList + `)`)
var checkDenyRelativePath = regexp.MustCompile(`(?m)(` + regexDenyFileNameCharList + regexDenyFileName + `)`)
func (s *StringValidator) IsValidFilePath(str string) bool {
	ret := checkDenyRelativePath.MatchString(str)
	return !ret
}