// validateMap validates a slice/array of validatable elements
779379
func validateSlice(rv reflect.Value) error {
	errs := Errors{}
	l := rv.Len()
	for i := 0; i < l; i++ {
		if ev := rv.Index(i).Interface(); ev != nil {
			if err := ev.(Validatable).Validate(); err != nil {
				errs[strconv.Itoa(i)] = err
			}
		}
	}
	if len(errs) > 0 {
		return errs
	}
	return nil
}
214603
func (p *parserMixin) StringMap() (target *map[string]string) {
	target = &(map[string]string{})
	p.StringMapVar(target)
	return
}
1336340
func RenderMap(v interface{}, ctx *Context, f *RenderFilter) (map[string]interface{}, error) {
	// First decode it into the map
	var m map[string]interface{}
	if err := mapstructure.Decode(v, &m); err != nil {
		return nil, err
	}

	// Now go through each value and render it
	for k, raw := range m {
		// Always validate every field
		if err := ValidateInterface(raw, ctx); err != nil {
			return nil, fmt.Errorf("invalid '%s': %s", k, err)
		}

		if !f.include(k) {
			continue
		}

		raw, err := RenderInterface(raw, ctx)
		if err != nil {
			return nil, fmt.Errorf("render '%s': %s", k, err)
		}

		m[k] = raw
	}

	return m, nil
}
685006
func (pTypeDef *MapArrayTest) Validate() error {
	if pTypeDef.Locations == nil {
		return fmt.Errorf("MapArrayTest: Missing required field: locations")
	}
	return nil
}
444921
func StringValueMap(src map[string]*string) map[string]string {
	dst := make(map[string]string)
	for k, val := range src {
		if val != nil {
			dst[k] = *val
		}
	}
	return dst
}
776624
func ParseMap(data string) (map[string]string, error) {
	keys, values, err := ParseOrderedMap(data)
	if err != nil {
		return nil, err
	}
	res := make(map[string]string, len(keys))
	for i, key := range keys {
		res[key] = values[i]
	}
	return res, nil
}
1088248
func (c Certificates) AsMap() CertificateMap {
	certMap := make(map[string]*KubeadmCert)
	for _, cert := range c {
		certMap[cert.Name] = cert
	}

	return certMap
}
517906
func applyMap(dst reflect.Value, src reflect.Value) error {
	dstKeyType := dst.Type().Key()
	dstValType := dst.Type().Elem()

	dst.Set(reflect.MakeMap(dst.Type()))
	for _, k := range src.MapKeys() {
		if k.Type().Kind() == reflect.Interface {
			k = k.Elem()
		}
		var err error
		if k, err = convert(k, dstKeyType); err != nil {
			return fmt.Errorf("key '%v' invalid type: %s", k.Interface(), err)
		}

		v := src.MapIndex(k)
		if v, err = convert(v, dstValType); err != nil {
			return fmt.Errorf("value for key '%v' invalid type: %s", k.Interface(), err)
		}
		dst.SetMapIndex(k, v)
	}
	return nil
}
177930
func ValidateImageStreamMapping(mapping *imageapi.ImageStreamMapping) field.ErrorList {
	result := validation.ValidateObjectMeta(&mapping.ObjectMeta, true, path.ValidatePathSegmentName, field.NewPath("metadata"))

	hasRepository := len(mapping.DockerImageRepository) != 0
	hasName := len(mapping.Name) != 0
	switch {
	case hasRepository:
		if _, err := imageapi.ParseDockerImageReference(mapping.DockerImageRepository); err != nil {
			result = append(result, field.Invalid(field.NewPath("dockerImageRepository"), mapping.DockerImageRepository, err.Error()))
		}
	case hasName:
	default:
		result = append(result, field.Required(field.NewPath("name"), ""))
		result = append(result, field.Required(field.NewPath("dockerImageRepository"), ""))
	}

	if reasons := validation.ValidateNamespaceName(mapping.Namespace, false); len(reasons) != 0 {
		result = append(result, field.Invalid(field.NewPath("metadata", "namespace"), mapping.Namespace, strings.Join(reasons, ", ")))
	}
	if len(mapping.Tag) == 0 {
		result = append(result, field.Required(field.NewPath("tag"), ""))
	}
	if errs := validateImage(&mapping.Image, field.NewPath("image")); len(errs) != 0 {
		result = append(result, errs...)
	}
	return result
}
1239288
func validateAnnotations(removeAnnotations []string, newAnnotations map[string]string) error {
	var modifyRemoveBuf bytes.Buffer
	for _, removeAnnotation := range removeAnnotations {
		if _, found := newAnnotations[removeAnnotation]; found {
			if modifyRemoveBuf.Len() > 0 {
				modifyRemoveBuf.WriteString(", ")
			}
			modifyRemoveBuf.WriteString(fmt.Sprintf(removeAnnotation))
		}
	}
	if modifyRemoveBuf.Len() > 0 {
		return fmt.Errorf("can not both modify and remove the following annotation(s) in the same command: %s", modifyRemoveBuf.String())
	}

	return nil
}
1134902
func ValidateMetadata(meta map[string]string, allowConsulPrefix bool) error {
	if len(meta) > metaMaxKeyPairs {
		return fmt.Errorf("Node metadata cannot contain more than %d key/value pairs", metaMaxKeyPairs)
	}

	for key, value := range meta {
		if err := validateMetaPair(key, value, allowConsulPrefix); err != nil {
			return fmt.Errorf("Couldn't load metadata pair ('%s', '%s'): %s", key, value, err)
		}
	}

	return nil
}
462051
func (s Strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
	mapping := obj.(*imageapi.ImageStreamMapping)
	return validation.ValidateImageStreamMapping(mapping)
}
1210061
func formatMap(m map[string]string) (fmtStr string) {
	for key, value := range m {
		fmtStr += fmt.Sprintf("%v=%q\n", key, value)
	}

	return
}
1131784
func validateAndMap(obj reflect.Value, ctx *macaron.Context, errors Errors, ifacePtr ...interface{}) {
	ctx.Invoke(Validate(obj.Interface()))
	errors = append(errors, getErrors(ctx)...)
	ctx.Map(errors)
	ctx.Map(obj.Elem().Interface())
	if len(ifacePtr) > 0 {
		ctx.MapTo(obj.Elem().Interface(), ifacePtr[0])
	}
}
1245438
func Validate(request *restful.Request, params []*restful.Parameter) (map[string][]string, error) {
	res := make(map[string][]string)

	for _, p := range params {
		var t string
		values := []string{}

		switch p.Kind() {
		case restful.QueryParameterKind:
			t = "Query"
			if ql, ok := request.Request.URL.Query()[p.Data().Name]; ok {
				for _, q := range ql {
					values = append(values, q)
				}
			}

		case restful.PathParameterKind:
			t = "Path"
			values = append(values, request.PathParameter(p.Data().Name))
		}

		if p.Data().Required && len(values) == 0 {
			return res, errors.New(t + "-Parameter '" + p.Data().Name + "' is required but missing")
		}

		for _, v := range values {
			res[p.Data().Name] = append(res[p.Data().Name], decodeParam(v))
		}
	}

	return res, nil
}
652753
func (p *Polygon) Validate() error {
	for i, l := range p.loops {
		// Check for loop errors that don't require building a ShapeIndex.
		if err := l.findValidationErrorNoIndex(); err != nil {
			return fmt.Errorf("loop %d: %v", i, err)
		}
		// Check that no loop is empty, and that the full loop only appears in the
		// full polygon.
		if l.IsEmpty() {
			return fmt.Errorf("loop %d: empty loops are not allowed", i)
		}
		if l.IsFull() && len(p.loops) > 1 {
			return fmt.Errorf("loop %d: full loop appears in non-full polygon", i)
		}
	}

	// TODO(roberts): Uncomment the remaining checks when they are completed.

	// Check for loop self-intersections and loop pairs that cross
	// (including duplicate edges and vertices).
	// if findSelfIntersection(p.index) {
	//	return fmt.Errorf("polygon has loop pairs that cross")
	// }

	// Check whether initOriented detected inconsistent loop orientations.
	// if p.hasInconsistentLoopOrientations {
	// 	return fmt.Errorf("inconsistent loop orientations detected")
	// }

	// Finally, verify the loop nesting hierarchy.
	return p.findLoopNestingError()
}
232185
func CreateMap(values ...interface{}) (map[string]interface{}, error) {
	if len(values)%2 != 0 {
		return nil, errors.New("invalid map call")
	}
	dict := make(map[string]interface{}, len(values)/2)
	for i := 0; i < len(values); i += 2 {
		key, ok := values[i].(string)
		if !ok {
			return nil, errors.New("map keys must be strings")
		}
		dict[key] = values[i+1]
	}
	return dict, nil
}