import { FileAdapter, ProcessorInput } from '../utils/io'; import { ZipAdapter } from '../utils/zip'; /** * Custom error class for validation errors * Can be marked as a blocker to stop validation immediately */ export declare class ValidationError extends Error { blocker: boolean; constructor(message: string, blocker?: boolean); } /** * Represents a single validation check with its result */ export interface ValidationCheck { /** Type/category of the check (e.g., 'json_parse', 'grid', 'buttons') */ type: string; /** Human-readable description of what is being checked */ description: string; /** Whether the check passed */ valid: boolean; /** Error message if the check failed */ error?: string; /** Non-blocking warnings */ warnings?: string[]; } /** * Complete validation result for a file */ export interface ValidationResult { /** Name of the file that was validated */ filename: string; /** Size of the file in bytes */ filesize: number; /** Format identifier (e.g., 'obf', 'gridset', 'snap') */ format: string; /** Overall validity - true if no errors */ valid: boolean; /** Total number of errors found */ errors: number; /** Total number of warnings found */ warnings: number; /** Array of individual validation checks */ results: ValidationCheck[]; /** Nested validation results (e.g., boards within an OBZ) */ sub_results?: ValidationResult[]; } /** * Options for validation behavior */ export interface ValidationConfig { /** Whether to include warnings in validation (default: true) */ includeWarnings?: boolean; /** Whether to stop on first blocker error (default: true) */ stopOnBlocker?: boolean; /** Custom validation rules to apply */ customRules?: ValidationRule[]; /** Adapter for handling file IO (optional) */ fileAdapter: FileAdapter; /** Adapter for handling ZIP files (optional) */ zipAdapter: (input: ProcessorInput) => Promise; } export type ValidationOptions = Partial; /** * Custom validation rule that can be added */ export interface ValidationRule { type: string; description: string; check: (data: any) => Promise | boolean; errorMessage?: string; } /** * Error wrapper that carries a structured ValidationResult so callers * can surface actionable details instead of generic exceptions. */ export declare class ValidationFailureError extends Error { validationResult: ValidationResult; originalError?: unknown; constructor(message: string, validationResult: ValidationResult, originalError?: unknown); } /** * Build a minimal ValidationResult for situations where we cannot run * the full validator (e.g., early parse failure) but still want * structured feedback for the caller. */ export declare function buildValidationResultFromMessage(params: { filename: string; filesize: number; format: string; message: string; type?: string; description?: string; }): ValidationResult;