/** * cli:extract-doc — validate.ts * * Structural Zod validation + a non-blocking sanity check that the project * path exists. Never blocks on missing layers (Domain/Api/web): extraction * degrades gracefully and reports what it could not find as warnings, so a * partially-scaffolded project still yields a useful report. */ import { existsSync } from 'node:fs' import { ExtractDocInputSchema, type ValidationResult } from './types.js' export function validate(raw: unknown): ValidationResult { const result = ExtractDocInputSchema.safeParse(raw) if (!result.success) { return { valid: false, errors: result.error.issues.map((i) => `[${i.path.join('.')}] ${i.message}`), warnings: [], } } if (!existsSync(result.data.projectPath)) { return { valid: false, errors: [`projectPath does not exist: ${result.data.projectPath}`], warnings: [], } } const warnings: string[] = [] if (result.data.type === 'user' && !result.data.application) { warnings.push( 'No `application` provided for a user-type doc — the namespace/route suggestions will omit the app prefix.', ) } return { valid: true, errors: [], warnings } }