MCPcopy
hub / github.com/Fission-AI/OpenSpec / validateSpecContent

Method validateSpecContent

src/core/validation/validator.ts:57–73  ·  view source on GitHub ↗

* Validate spec content from a string (used for pre-write validation of rebuilt specs)

(specName: string, content: string)

Source from the content-addressed store, hash-verified

55 * Validate spec content from a string (used for pre-write validation of rebuilt specs)
56 */
57 async validateSpecContent(specName: string, content: string): Promise<ValidationReport> {
58 const issues: ValidationIssue[] = [];
59 try {
60 const parser = new MarkdownParser(content);
61 const spec = parser.parseSpec(specName);
62 const result = SpecSchema.safeParse(spec);
63 if (!result.success) {
64 issues.push(...this.convertZodErrors(result.error));
65 }
66 issues.push(...this.applySpecRules(spec, content));
67 } catch (error) {
68 const baseMessage = error instanceof Error ? error.message : 'Unknown error';
69 const enriched = this.enrichTopLevelError(specName, baseMessage);
70 issues.push({ level: 'ERROR', path: 'file', message: enriched });
71 }
72 return this.createReport(issues);
73 }
74
75 async validateChange(filePath: string): Promise<ValidationReport> {
76 const issues: ValidationIssue[] = [];

Callers 2

applySpecsFunction · 0.95
runMethod · 0.80

Calls 5

parseSpecMethod · 0.95
convertZodErrorsMethod · 0.95
applySpecRulesMethod · 0.95
enrichTopLevelErrorMethod · 0.95
createReportMethod · 0.95

Tested by

no test coverage detected