(path string, schema map[string]json.RawMessage, value any)
| 128 | } |
| 129 | |
| 130 | func 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 | |
| 157 | func validateSchemaObjectNode(path string, schema map[string]json.RawMessage, value any) error { |
| 158 | objectValue, ok := value.(map[string]any) |
no test coverage detected