| 589 | } |
| 590 | |
| 591 | func 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 | |
| 620 | func handleMapString(r Registry, s *Schema, path *PathBuffer, mode ValidateMode, m map[string]any, res *ValidateResult) { |
| 621 | if s.MinProperties != nil { |