func SetPrintJSON(printJSON bool) {
	defaultValidator.SetPrintJSON(printJSON)
}
SetPrintJSON allows you to print errors with json tag names present in struct tags
package validator
import (
	"bytes"
	"errors"
	"fmt"
	"reflect"
	"regexp"
	"strings"
)
type TextErr struct {
	Err error
}
func (t TextErr) Error() string {
	return t.Err.Error()
}
func (t TextErr) MarshalText() ([]byte, error) {
	return []byte(t.Err.Error()), nil
}
var (
	ErrZeroValue = TextErr{errors.New("zero value")}
	ErrMin = TextErr{errors.New("less than min")}
	ErrMax = TextErr{errors.New("greater than max")}
	ErrLen = TextErr{errors.New("invalid length")}
	ErrRegexp = TextErr{errors.New("regular expression mismatch")}
	ErrUnsupported = TextErr{errors.New("unsupported type")}
	ErrBadParameter = TextErr{errors.New("bad parameter")}
	ErrUnknownTag = TextErr{errors.New("unknown tag")}
	ErrInvalid = TextErr{errors.New("invalid value")}
	ErrCannotValidate = TextErr{errors.New("cannot validate unexported struct")}
)
type ErrorMap map[string]ErrorArray
func (err ErrorMap) Error() string {
	var b bytes.Buffer
	for k, errs := range err {
		if len(errs) > 0 {
			b.WriteString(fmt.Sprintf("%s: %s, ", k, errs.Error()))
		}
	}
	return strings.TrimSuffix(b.String(), ", ")
}
type ErrorArray []error
func (err ErrorArray) Error() string {
	var b bytes.Buffer
	for _, errs := range err {
		b.WriteString(fmt.Sprintf("%s, ", errs.Error()))
	}
	errs := b.String()
	return strings.TrimSuffix(errs, ", ")
}
type ValidationFunc func(v interface{}, param string) error
type Validator struct {
	validationFuncs map[string]ValidationFunc
	tagName string
	printJSON bool
}
var defaultValidator = NewValidator()
func NewValidator() *Validator {
	return &Validator{
		tagName: "validate",
		validationFuncs: map[string]ValidationFunc{
			"nonzero": nonzero,
			"len":     length,
			"min":     min,
			"max":     max,
			"regexp":  regex,
			"nonnil":  nonnil,
		},
		printJSON: false,
	}
}
func SetTag(tag string) {
	defaultValidator.SetTag(tag)
}
func (mv *Validator) SetTag(tag string) {
	mv.tagName = tag
}
func WithTag(tag string) *Validator {
	return defaultValidator.WithTag(tag)
}
func (mv *Validator) WithTag(tag string) *Validator {
	v := mv.copy()
	v.SetTag(tag)
	return v
}