import { ScaffoldMigrationInputSchema, type ValidationResult } from './types.js'
import { existsSync } from 'node:fs'

export function validate(raw: unknown): ValidationResult {
  const r = ScaffoldMigrationInputSchema.safeParse(raw)
  if (!r.success) return { valid: false, errors: r.error.issues.map(i => `[${i.path.join('.')}] ${i.message}`), warnings: [] }
  if (!existsSync(r.data.projectPath)) return { valid: false, errors: [`Project not found: ${r.data.projectPath}`], warnings: [] }
  return { valid: true, errors: [], warnings: [] }
}
