func (v *Validator) SetErrorFactory(errFactory func(failPath, msg string) error) *Validator {
	if errFactory == nil {
		errFactory = defaultErrorFactory
	}
	v.errFactory = errFactory
	return v
}
SetErrorFactory customizes the factory of validation error.
NOTE:
If errFactory==nil, the default is used
package validator
import (
	"errors"
	"io"
	"reflect"
	"strings"
	_ "unsafe"
	tagexpr "github.com/bytedance/go-tagexpr/v2"
)
const (
	MatchExprName = tagexpr.DefaultExprName
	ErrMsgExprName = "msg"
)
type Validator struct {
	vm         *tagexpr.VM
	errFactory func(failPath, msg string) error
}
func New(tagName string) *Validator {
	v := &Validator{
		vm:         tagexpr.New(tagName),
		errFactory: defaultErrorFactory,
	}
	return v
}
func (v *Validator) VM() *tagexpr.VM {
	return v.vm
}
func (v *Validator) Validate(value interface{}, checkAll ...bool) error {
	var all bool
	if len(checkAll) > 0 {
		all = checkAll[0]
	}
	var errs = make([]error, 0, 8)
	err := v.vm.RunAny(value, func(te *tagexpr.TagExpr, err error) error {
		if err != nil {
			errs = append(errs, err)
			if all {
				return nil
			}
			return io.EOF
		}
		nilParentFields := make(map[string]bool, 16)
		err = te.Range(func(eh *tagexpr.ExprHandler) error {
			if strings.Contains(eh.StringSelector(), tagexpr.ExprNameSeparator) {
				return nil
			}
			r := eh.Eval()
			if r == nil {
				return nil
			}
			rerr, ok := r.(error)
			if !ok && tagexpr.FakeBool(r) {
				return nil
			}
			if pfs, ok := eh.ExprSelector().ParentField(); ok {
				if nilParentFields[pfs] {
					return nil
				}
				if fh, ok := eh.TagExpr().Field(pfs); ok {
					v := fh.Value(false)
					if !v.IsValid() || (v.Kind() == reflect.Ptr && v.IsNil()) {
						nilParentFields[pfs] = true
						return nil
					}
				}
			}
			msg := eh.TagExpr().EvalString(eh.StringSelector() + tagexpr.ExprNameSeparator + ErrMsgExprName)
			if msg == "" && rerr != nil {
				msg = rerr.Error()
			}
			errs = append(errs, v.errFactory(eh.Path(), msg))
			if all {
				return nil
			}
			return io.EOF
		})
		if err != nil && !all {
			return err
		}
		return nil
	})
	if err != io.EOF && err != nil {
		return err
	}
	switch len(errs) {
	case 0:
		return nil
	case 1:
		return errs[0]
	default:
		var errStr string
		for _, e := range errs {
			errStr += e.Error() + "\t"
		}
		return errors.New(errStr[:len(errStr)-1])
	}
}