import { Logger } from './logger.js';
/**
 * Validation engine for comparing extracted data against expectations.
 */
export class Validator {
    /**
     * Compares extracted data with expected data.
     * Throws Error if mismatch found.
     */
    static validate(extracted, expected) {
        const errors = [];
        for (const [key, expectedValue] of Object.entries(expected)) {
            const actualValue = extracted[key];
            if (actualValue === undefined) {
                errors.push(`Missing key in extracted data: "${key}"`);
                continue;
            }
            // Simple string comparison for now. 
            // In production, we might want to handle types (numbers, dates).
            if (String(actualValue).toLowerCase() !== String(expectedValue).toLowerCase()) {
                errors.push(`Value mismatch for key "${key}": Expected "${expectedValue}", Got "${actualValue}"`);
            }
        }
        if (errors.length > 0) {
            Logger.error('Validation failed', errors);
            throw new Error(`Validation Failed:\n${errors.join('\n')}`);
        }
        Logger.log('Validation passed successfully!');
    }
}
