func NewPathValidator(idValidator ValidateFn) ValidateFn {
	return func(path string) error {
		pathArr := strings.Split(path, "/")
		if len(pathArr) > 0 && pathArr[0] == path {
			return sdkerrors.Wrapf(ErrInvalidPath, "path %s doesn't contain any separator '/'", path)
		}
		for _, p := range pathArr {
			if p == "" {
				return sdkerrors.Wrapf(ErrInvalidPath, "path %s cannot begin or end with '/'", path)
			}
			if err := idValidator(p); err != nil {
				return err
			}
			if err := defaultIdentifierValidator(p, 1, DefaultMaxCharacterLength); err != nil {
				return sdkerrors.Wrapf(err, "path %s contains an invalid identifier: '%s'", path, p)
			}
		}
		return nil
	}
}
NewPathValidator takes in a Identifier Validator function and returns
a Path Validator function which requires path to consist of `/`-separated valid identifiers,
where a valid identifier is between 1-64 characters, contains only alphanumeric and some allowed
special characters (see IsValidID), and satisfies the custom `idValidator` function.
package host
import (
	"regexp"
	"strings"
	sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
const DefaultMaxCharacterLength = 64
var IsValidID = regexp.MustCompile(`^[a-zA-Z0-9\.\_\+\-\#\[\]\<\>]+$`).MatchString
var IsValidRule = regexp.MustCompile(`^(([a-zA-Z0-9\.\_\+\-\#\[\]\<\>]{1,64}|[*]),){2}([a-zA-Z0-9\.\_\+\-\#\[\]\<\>]{1,64}|[*])$`).MatchString
type ValidateFn func(string) error
func defaultIdentifierValidator(id string, min, max int) error {  
	if strings.TrimSpace(id) == "" {
		return sdkerrors.Wrap(ErrInvalidID, "identifier cannot be blank")
	}
	if strings.Contains(id, "/") {
		return sdkerrors.Wrapf(ErrInvalidID, "identifier %s cannot contain separator '/'", id)
	}
	if len(id) < min || len(id) > max {
		return sdkerrors.Wrapf(ErrInvalidID, "identifier %s has invalid length: %d, must be between %d-%d characters", id, len(id), min, max)
	}
	if !IsValidID(id) {
		return sdkerrors.Wrapf(
			ErrInvalidID,
			"identifier %s must contain only alphanumeric or the following characters: '.', '_', '+', '-', '#', '[', ']', '<', '>'",
			id,
		)
	}
	return nil
}
func defaultRuleValidator(rule string) error {
	if !IsValidRule(rule) {
		return sdkerrors.Wrapf(
			ErrInvalidRule,
			"rule %s must contain two ','",
			rule,
		)
	}
	return nil
}
func ClientIdentifierValidator(id string) error {
	return defaultIdentifierValidator(id, 9, DefaultMaxCharacterLength)
}
func RoutingRulesValidator(rules []string) error {
	for _, rule := range rules {
		if err := defaultRuleValidator(rule); err != nil {
			return err
		}
	}
	return nil
}
func DestChainValidator(id string) error {
	return defaultIdentifierValidator(id, 8, DefaultMaxCharacterLength)
}
func SourceChainValidator(id string) error {
	return defaultIdentifierValidator(id, 2, DefaultMaxCharacterLength)
}