MCPcopy Create free account
hub / github.com/compozy/agh / validateSchemaArrayNode

Function validateSchemaArrayNode

internal/tools/schema.go:130–155  ·  view source on GitHub ↗
(path string, schema map[string]json.RawMessage, value any)

Source from the content-addressed store, hash-verified

128}
129
130func validateSchemaArrayNode(path string, schema map[string]json.RawMessage, value any) error {
131 arrayValue, ok := value.([]any)
132 if !ok {
133 return nil
134 }
135 minItems, ok, err := schemaNonNegativeInteger(schema["minItems"])
136 if err != nil {
137 return fmt.Errorf("%s.minItems: %w", path, err)
138 }
139 if ok && len(arrayValue) < minItems {
140 return fmt.Errorf("%s: array length %d is less than minItems %d", path, len(arrayValue), minItems)
141 }
142 items, ok, err := schemaNode(schema["items"])
143 if err != nil {
144 return fmt.Errorf("%s.items: %w", path, err)
145 }
146 if !ok {
147 return nil
148 }
149 for idx, item := range arrayValue {
150 if err := validateSchemaNode(fmt.Sprintf("%s[%d]", path, idx), items, item); err != nil {
151 return err
152 }
153 }
154 return nil
155}
156
157func validateSchemaObjectNode(path string, schema map[string]json.RawMessage, value any) error {
158 objectValue, ok := value.(map[string]any)

Callers 1

validateSchemaNodeFunction · 0.85

Calls 3

schemaNonNegativeIntegerFunction · 0.85
schemaNodeFunction · 0.85
validateSchemaNodeFunction · 0.85

Tested by

no test coverage detected