MCPcopy
hub / github.com/danielgtaylor/huma / handleArray

Function handleArray

validate.go:591–618  ·  view source on GitHub ↗
(r Registry, s *Schema, path *PathBuffer, mode ValidateMode, res *ValidateResult, arr []T)

Source from the content-addressed store, hash-verified

589}
590
591func handleArray[T any](r Registry, s *Schema, path *PathBuffer, mode ValidateMode, res *ValidateResult, arr []T) {
592 if s.MinItems != nil {
593 if len(arr) < *s.MinItems {
594 res.Add(path, arr, s.msgMinItems)
595 }
596 }
597 if s.MaxItems != nil {
598 if len(arr) > *s.MaxItems {
599 res.Add(path, arr, s.msgMaxItems)
600 }
601 }
602
603 if s.UniqueItems {
604 seen := make(map[any]struct{}, len(arr))
605 for _, item := range arr {
606 if _, ok := seen[item]; ok {
607 res.Add(path, arr, validation.MsgExpectedArrayItemsUnique)
608 }
609 seen[item] = struct{}{}
610 }
611 }
612
613 for i, item := range arr {
614 path.PushIndex(i)
615 Validate(r, s.Items, path, mode, item, res)
616 path.Pop()
617 }
618}
619
620func handleMapString(r Registry, s *Schema, path *PathBuffer, mode ValidateMode, m map[string]any, res *ValidateResult) {
621 if s.MinProperties != nil {

Callers 1

ValidateFunction · 0.85

Calls 4

ValidateFunction · 0.85
PushIndexMethod · 0.80
PopMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…