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

Function validateSchemaNode

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

Source from the content-addressed store, hash-verified

77}
78
79func validateSchemaNode(path string, schema map[string]json.RawMessage, value any) error {
80 types, err := schemaTypes(schema["type"])
81 if err != nil {
82 return fmt.Errorf("%s: %w", path, err)
83 }
84 if len(types) > 0 && !jsonValueMatchesAnyType(value, types) {
85 return fmt.Errorf("%s: expected %v, got %s", path, types, jsonValueType(value))
86 }
87 if err := validateSchemaEnum(path, schema["enum"], value); err != nil {
88 return err
89 }
90 if err := validateSchemaAllOf(path, schema["allOf"], value); err != nil {
91 return err
92 }
93 if err := validateSchemaAnyOf(path, schema["anyOf"], value); err != nil {
94 return err
95 }
96 if err := validateSchemaOneOf(path, schema["oneOf"], value); err != nil {
97 return err
98 }
99 if err := validateSchemaNot(path, schema["not"], value); err != nil {
100 return err
101 }
102 if err := validateSchemaStringNode(path, schema, value); err != nil {
103 return err
104 }
105 if err := validateSchemaArrayNode(path, schema, value); err != nil {
106 return err
107 }
108 if slices.Contains(types, schemaTypeObject) || jsonValueType(value) == schemaTypeObject {
109 return validateSchemaObjectNode(path, schema, value)
110 }
111 return nil
112}
113
114func validateSchemaStringNode(path string, schema map[string]json.RawMessage, value any) error {
115 stringValue, ok := value.(string)

Callers 7

validateJSONSchemaValueFunction · 0.85
validateSchemaArrayNodeFunction · 0.85
validateSchemaObjectNodeFunction · 0.85
validateSchemaAllOfFunction · 0.85
validateSchemaAnyOfFunction · 0.85
validateSchemaOneOfFunction · 0.85
validateSchemaNotFunction · 0.85

Calls 12

schemaTypesFunction · 0.85
jsonValueMatchesAnyTypeFunction · 0.85
jsonValueTypeFunction · 0.85
validateSchemaEnumFunction · 0.85
validateSchemaAllOfFunction · 0.85
validateSchemaAnyOfFunction · 0.85
validateSchemaOneOfFunction · 0.85
validateSchemaNotFunction · 0.85
validateSchemaStringNodeFunction · 0.85
validateSchemaArrayNodeFunction · 0.85
validateSchemaObjectNodeFunction · 0.85
ContainsMethod · 0.80

Tested by

no test coverage detected