MCPcopy Create free account
hub / github.com/agentrpc/agentrpc / validateProperty

Function validateProperty

sdk-node/src/util.ts:115–145  ·  view source on GitHub ↗
(
  key: string,
  value: JsonSchema,
)

Source from the content-addressed store, hash-verified

113 * Recursively validate $.properties
114 */
115const validateProperty = (
116 key: string,
117 value: JsonSchema,
118): ValidationError[] => {
119 let errors: ValidationError[] = [];
120 try {
121 validatePropertyName(key);
122 } catch (error) {
123 if (error instanceof Error) {
124 errors.push({
125 path: `${key}`,
126 error: error.message,
127 });
128 } else {
129 throw error;
130 }
131 }
132 if (value && typeof value === "object" && "properties" in value) {
133 const properties = (value.properties as Record<string, JsonSchema>) || {};
134
135 errors = errors.concat(
136 Object.keys(properties)
137 .map((key) => {
138 return validateProperty(key, properties[key]);
139 })
140 .flat(),
141 );
142 }
143
144 return errors;
145};
146
147/*
148 * Accepts an AJV compilation error and extracts the error details from the message.

Callers 1

validateFunctionSchemaFunction · 0.85

Calls 1

validatePropertyNameFunction · 0.85

Tested by

no test coverage detected