MCPcopy Create free account
hub / github.com/echoVic/blade-code / validateTemplate

Method validateTemplate

src/prompt/PromptTemplate.ts:470–485  ·  view source on GitHub ↗

* 验证模板

(template: PromptTemplate)

Source from the content-addressed store, hash-verified

468 * 验证模板
469 */
470 private validateTemplate(template: PromptTemplate): void {
471 if (!template.id || !template.name || !template.template) {
472 throw new Error('模板缺少必要字段: id, name, template');
473 }
474
475 if (this.templates.has(template.id)) {
476 throw new Error(`模板ID已存在: ${template.id}`);
477 }
478
479 // 验证变量定义
480 template.variables.forEach(variable => {
481 if (!variable.name || !variable.type) {
482 throw new Error('变量缺少必要字段: name, type');
483 }
484 });
485 }
486
487 /**
488 * 验证变量

Callers 1

addTemplateMethod · 0.95

Calls 1

hasMethod · 0.80

Tested by

no test coverage detected