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

Method validateSpec

src/core/validation/validator.ts:24–52  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

22 }
23
24 async validateSpec(filePath: string): Promise<ValidationReport> {
25 const issues: ValidationIssue[] = [];
26 const specName = this.extractNameFromPath(filePath);
27 try {
28 const content = readFileSync(filePath, 'utf-8');
29 const parser = new MarkdownParser(content);
30
31 const spec = parser.parseSpec(specName);
32
33 const result = SpecSchema.safeParse(spec);
34
35 if (!result.success) {
36 issues.push(...this.convertZodErrors(result.error));
37 }
38
39 issues.push(...this.applySpecRules(spec, content));
40
41 } catch (error) {
42 const baseMessage = error instanceof Error ? error.message : 'Unknown error';
43 const enriched = this.enrichTopLevelError(specName, baseMessage);
44 issues.push({
45 level: 'ERROR',
46 path: 'file',
47 message: enriched,
48 });
49 }
50
51 return this.createReport(issues);
52 }
53
54 /**
55 * Validate spec content from a string (used for pre-write validation of rebuilt specs)

Callers 5

registerSpecCommandFunction · 0.95
validateByTypeMethod · 0.95
runBulkValidationMethod · 0.95
validation.test.tsFile · 0.80

Calls 6

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

Tested by

no test coverage detected