MCPcopy Create free account
hub / github.com/ShipSecAI/studio / validateParameterSchema

Function validateParameterSchema

packages/component-sdk/src/schema-validation.ts:137–168  ·  view source on GitHub ↗
(
  schema: z.ZodTypeAny
)

Source from the content-addressed store, hash-verified

135}
136
137export function validateParameterSchema(
138 schema: z.ZodTypeAny
139): SchemaValidationResult {
140 const errors: string[] = [];
141 const objectSchema = unwrapToObject(schema);
142 if (!objectSchema) {
143 return { valid: true, errors };
144 }
145 const shape = getObjectShape(objectSchema);
146
147 for (const [fieldName, fieldSchema] of Object.entries(shape)) {
148 const typedSchema = fieldSchema as z.ZodTypeAny;
149 const paramMeta = getParamMeta(typedSchema);
150 if (!paramMeta) {
151 errors.push(`Field "${fieldName}": parameters require param() metadata`);
152 continue;
153 }
154
155 if (!paramMeta.label) {
156 errors.push(`Field "${fieldName}": param() metadata requires a label`);
157 }
158
159 if (!paramMeta.editor) {
160 errors.push(`Field "${fieldName}": param() metadata requires an editor type`);
161 }
162 }
163
164 return {
165 valid: errors.length === 0,
166 errors,
167 };
168}
169
170export interface ValidationOptions {
171 /** Maximum nesting depth for port-visible fields (default: 1) */

Callers 2

registerMethod · 0.90
param-meta.test.tsFile · 0.90

Calls 4

getParamMetaFunction · 0.90
unwrapToObjectFunction · 0.70
getObjectShapeFunction · 0.70
pushMethod · 0.65

Tested by

no test coverage detected