func (f *defaultFormats) GetType(name string) (reflect.Type, bool) {
	f.Lock()
	defer f.Unlock()
	nme := f.normalizeName(name)
	for _, v := range f.data {
		if v.Name == nme {
			return v.Type, true
		}
	}
	return nil, false
}
GetType gets the type for the specified name
package strfmt
import (
	"encoding"
	"fmt"
	"reflect"
	"strings"
	"sync"
	"time"
	"github.com/mitchellh/mapstructure"
	"k8s.io/kube-openapi/pkg/validation/errors"
)
var Default = NewSeededFormats(nil, nil)
type Validator func(string) bool
type Format interface {
	String() string
	encoding.TextMarshaler
	encoding.TextUnmarshaler
}
type Registry interface {
	Add(string, Format, Validator) bool
	DelByName(string) bool
	GetType(string) (reflect.Type, bool)
	ContainsName(string) bool
	Validates(string, string) bool
	Parse(string, string) (interface{}, error)
	MapStructureHookFunc() mapstructure.DecodeHookFunc
}
type knownFormat struct {
	Name      string
	OrigName  string
	Type      reflect.Type
	Validator Validator
}
type NameNormalizer func(string) string
func DefaultNameNormalizer(name string) string {
	return strings.Replace(name, "-", "", -1)
}
type defaultFormats struct {
	sync.Mutex
	data          []knownFormat
	normalizeName NameNormalizer
}
func NewFormats() Registry {
	return NewSeededFormats(Default.(*defaultFormats).data, nil)
}
func NewSeededFormats(seeds []knownFormat, normalizer NameNormalizer) Registry {
	if normalizer == nil {
		normalizer = DefaultNameNormalizer
	}
	d := append([]knownFormat(nil), seeds...)
	return &defaultFormats{
		data:          d,
		normalizeName: normalizer,
	}
}
func (f *defaultFormats) MapStructureHookFunc() mapstructure.DecodeHookFunc {
	return func(from reflect.Type, to reflect.Type, data interface{}) (interface{}, error) {
		if from.Kind() != reflect.String {
			return data, nil
		}
		for _, v := range f.data {
			tpe, _ := f.GetType(v.Name)
			if to == tpe {
				switch v.Name {
				case "date":
					d, err := time.Parse(RFC3339FullDate, data.(string))
					if err != nil {
						return nil, err
					}
					return Date(d), nil
				case "datetime":
					input := data.(string)
					if len(input) == 0 {
						return nil, fmt.Errorf("empty string is an invalid datetime format")
					}
					return ParseDateTime(input)
				case "duration":
					dur, err := ParseDuration(data.(string))
					if err != nil {
						return nil, err
					}
					return Duration(dur), nil
				case "uri":
					return URI(data.(string)), nil
				case "email":
					return Email(data.(string)), nil
				case "uuid":
					return UUID(data.(string)), nil
				case "uuid3":
					return UUID3(data.(string)), nil
				case "uuid4":
					return UUID4(data.(string)), nil
				case "uuid5":
					return UUID5(data.(string)), nil
				case "hostname":
					return Hostname(data.(string)), nil
				case "ipv4":
					return IPv4(data.(string)), nil
				case "ipv6":
					return IPv6(data.(string)), nil
				case "cidr":
					return CIDR(data.(string)), nil
				case "mac":
					return MAC(data.(string)), nil
				case "isbn":
					return ISBN(data.(string)), nil
				case "isbn10":
					return ISBN10(data.(string)), nil
				case "isbn13":
					return ISBN13(data.(string)), nil
				case "creditcard":
					return CreditCard(data.(string)), nil
				case "ssn":
					return SSN(data.(string)), nil
				case "hexcolor":
					return HexColor(data.(string)), nil
				case "rgbcolor":
					return RGBColor(data.(string)), nil
				case "byte":
					return Base64(data.(string)), nil
				case "password":
					return Password(data.(string)), nil
				default:
					return nil, errors.InvalidTypeName(v.Name)
				}
			}
		}
		return data, nil
	}
}
func (f *defaultFormats) Add(name string, strfmt Format, validator Validator) bool {
	f.Lock()
	defer f.Unlock()
	nme := f.normalizeName(name)
	tpe := reflect.TypeOf(strfmt)
	if tpe.Kind() == reflect.Ptr {
		tpe = tpe.Elem()
	}
	for i := range f.data {
		v := &f.data[i]
		if v.Name == nme {
			v.Type = tpe
			v.Validator = validator
			return false
		}
	}
	f.data = append(f.data, knownFormat{Name: nme, OrigName: name, Type: tpe, Validator: validator})
	return true
}