import { useState } from "react"; import { ChevronDown, ChevronRight, ExternalLink } from "lucide-react"; import { Alert, AlertDescription, AlertTitle } from "@/src/components/ui/alert"; import { Button } from "@/src/components/ui/button"; import Link from "next/link"; type ValidationError = { datasetItemId: string; field: "input" | "expectedOutput"; errors: Array<{ path: string; message: string; keyword?: string; }>; }; type DatasetSchemaValidationErrorProps = { projectId: string; datasetId: string; errors: ValidationError[]; }; export const DatasetSchemaValidationError: React.FC< DatasetSchemaValidationErrorProps > = ({ projectId, datasetId, errors }) => { const [isExpanded, setIsExpanded] = useState(false); const errorCount = errors.length; const hasMoreThan10 = errorCount === 10; // Backend limits to 10 errors return ( Schema Validation Failed

{hasMoreThan10 ? `More than 10 items failed validation. Showing first 10 errors.` : `${errorCount} item${errorCount === 1 ? "" : "s"} failed validation.`}

{isExpanded && (
{errors.map((error, idx) => (
#{idx + 1} Item: {error.datasetItemId}
{error.field === "input" ? "Input" : "Expected Output"}
    {error.errors.map((err, errIdx) => (
  • Path {err.path} : {err.message}
  • ))}
))} {hasMoreThan10 && (

Fix these errors to see if there are additional validation issues.

)}
)}
); };