/** * validate-conventions/validate.ts — Args validation (Zod only). * No file I/O here — the actual checks live in execute.ts. */ import { ValidateConventionsArgsSchema, type ValidateConventionsArgs } from './types.js'; export interface ArgsValidationResult { valid: boolean; args: ValidateConventionsArgs | null; errors: string[]; } export function validateArgs(raw: unknown): ArgsValidationResult { const parsed = ValidateConventionsArgsSchema.safeParse(raw); if (!parsed.success) { return { valid: false, args: null, errors: parsed.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`), }; } const args = parsed.data; const errors: string[] = []; // If baseNamespace is provided, it should look like a proper .NET root namespace if (args.baseNamespace !== undefined) { if (!/^[A-Z][A-Za-z0-9]*(\.[A-Z][A-Za-z0-9]*)*$/.test(args.baseNamespace)) { errors.push( `baseNamespace "${args.baseNamespace}" should be dotted PascalCase (e.g. "SmartStack" or "Acme.Corp")`, ); } } return { valid: errors.length === 0, args, errors }; }