func NewHeaderValidator(name string, header *spec.Header, formats strfmt.Registry) *HeaderValidator {
	p := &HeaderValidator{name: name, header: header, KnownFormats: formats}
	p.validators = []valueValidator{
		&typeValidator{
			Type:     spec.StringOrArray([]string{header.Type}),
			Nullable: header.Nullable,
			Format:   header.Format,
			In:       "header",
			Path:     name,
		},
		p.stringValidator(),
		p.formatValidator(),
		p.numberValidator(),
		p.sliceValidator(),
		p.commonValidator(),
	}
	return p
}
NewHeaderValidator creates a new header validator object
package validate
import (
	"fmt"
	"reflect"
	"github.com/go-openapi/errors"
	"github.com/go-openapi/spec"
	"github.com/go-openapi/strfmt"
)
type EntityValidator interface {
	Validate(interface{}) *Result
}
type valueValidator interface {
	SetPath(path string)
	Applies(interface{}, reflect.Kind) bool
	Validate(interface{}) *Result
}
type itemsValidator struct {
	items        *spec.Items
	root         interface{}
	path         string
	in           string
	validators   []valueValidator
	KnownFormats strfmt.Registry
}
func newItemsValidator(path, in string, items *spec.Items, root interface{}, formats strfmt.Registry) *itemsValidator {
	iv := &itemsValidator{path: path, in: in, items: items, root: root, KnownFormats: formats}
	iv.validators = []valueValidator{
		&typeValidator{
			Type:     spec.StringOrArray([]string{items.Type}),
			Nullable: items.Nullable,
			Format:   items.Format,
			In:       in,
			Path:     path,
		},
		iv.stringValidator(),
		iv.formatValidator(),
		iv.numberValidator(),
		iv.sliceValidator(),
		iv.commonValidator(),
	}
	return iv
}
func (i *itemsValidator) Validate(index int, data interface{}) *Result {
	tpe := reflect.TypeOf(data)
	kind := tpe.Kind()
	mainResult := new(Result)
	path := fmt.Sprintf("%s.%d", i.path, index)
	for _, validator := range i.validators {
		validator.SetPath(path)
		if validator.Applies(i.root, kind) {
			result := validator.Validate(data)
			mainResult.Merge(result)
			mainResult.Inc()
			if result != nil && result.HasErrors() {
				return mainResult
			}
		}
	}
	return mainResult
}
func (i *itemsValidator) commonValidator() valueValidator {
	return &basicCommonValidator{
		In:      i.in,
		Default: i.items.Default,
		Enum:    i.items.Enum,
	}
}
func (i *itemsValidator) sliceValidator() valueValidator {
	return &basicSliceValidator{
		In:           i.in,
		Default:      i.items.Default,
		MaxItems:     i.items.MaxItems,
		MinItems:     i.items.MinItems,
		UniqueItems:  i.items.UniqueItems,
		Source:       i.root,
		Items:        i.items.Items,
		KnownFormats: i.KnownFormats,
	}
}
func (i *itemsValidator) numberValidator() valueValidator {
	return &numberValidator{
		In:               i.in,
		Default:          i.items.Default,
		MultipleOf:       i.items.MultipleOf,
		Maximum:          i.items.Maximum,
		ExclusiveMaximum: i.items.ExclusiveMaximum,
		Minimum:          i.items.Minimum,
		ExclusiveMinimum: i.items.ExclusiveMinimum,
		Type:             i.items.Type,
		Format:           i.items.Format,
	}
}
func (i *itemsValidator) stringValidator() valueValidator {
	return &stringValidator{
		In:              i.in,
		Default:         i.items.Default,
		MaxLength:       i.items.MaxLength,
		MinLength:       i.items.MinLength,
		Pattern:         i.items.Pattern,
		AllowEmptyValue: false,
	}
}
func (i *itemsValidator) formatValidator() valueValidator {
	return &formatValidator{
		In: i.in,
		Format:       i.items.Format,
		KnownFormats: i.KnownFormats,
	}
}
type basicCommonValidator struct {
	Path    string
	In      string
	Default interface{}
	Enum    []interface{}
}
func (b *basicCommonValidator) SetPath(path string) {
	b.Path = path
}
func (b *basicCommonValidator) Applies(source interface{}, kind reflect.Kind) bool {
	switch source.(type) {
	case *spec.Parameter, *spec.Schema, *spec.Header:
		return true
	}
	return false
}
func (b *basicCommonValidator) Validate(data interface{}) (res *Result) {
	if len(b.Enum) > 0 {
		for _, enumValue := range b.Enum {
			actualType := reflect.TypeOf(enumValue)
			if actualType != nil {  
				expectedValue := reflect.ValueOf(data)
				if expectedValue.IsValid() && expectedValue.Type().ConvertibleTo(actualType) {
					if reflect.DeepEqual(expectedValue.Convert(actualType).Interface(), enumValue) {
						return nil
					}
				}
			}
		}
		return errorHelp.sErr(errors.EnumFail(b.Path, b.In, data, b.Enum))
	}
	return nil
}
type HeaderValidator struct {
	name         string
	header       *spec.Header
	validators   []valueValidator
	KnownFormats strfmt.Registry
}