import { ListSpecSchema, type ListSpec } from './types.js';

export interface ValidationResult {
  valid: boolean;
  data?: ListSpec;
  blockers: string[];
  warnings: string[];
}

export function validate(raw: unknown): ValidationResult {
  const blockers: string[] = [];
  const parsed = ListSpecSchema.safeParse(raw);
  if (!parsed.success) {
    for (const issue of parsed.error.issues) {
      blockers.push(`[${issue.path.join('.')}] ${issue.message}`);
    }
    return { valid: false, blockers, warnings: [] };
  }
  return { valid: true, data: parsed.data, blockers, warnings: [] };
}
