( schema: z.ZodTypeAny )
| 135 | } |
| 136 | |
| 137 | export 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 | |
| 170 | export interface ValidationOptions { |
| 171 | /** Maximum nesting depth for port-visible fields (default: 1) */ |
no test coverage detected