/**
 * cli:compute-page-diff — validate.ts
 *
 * Pure input validation (no I/O). Mirrors the validate/execute split used by
 * every SmartStack dev CLI.
 */
import { ComputePageDiffInputSchema } from './types.js'
import type { ValidationResult } from './types.js'

export function validate(raw: unknown): ValidationResult {
  const parsed = ComputePageDiffInputSchema.safeParse(raw)
  if (!parsed.success) {
    return {
      valid: false,
      errors: parsed.error.issues.map((i) => `${i.path.join('.') || '(root)'}: ${i.message}`),
      warnings: [],
    }
  }
  return { valid: true, errors: [], warnings: [], spec: parsed.data }
}
