UNPKG

@accounter/server

Version:
42 lines 1.34 kB
import { parseReport } from '../parsers/parse-report.js'; import { validateData } from './validate-data.js'; /** * Validates a SHAAM6111 report content string. * @param content The raw content of the SHAAM6111 report as a string. * @returns A ValidationResult object containing validation status and aggregated errors. */ export function validateReport(content) { try { // Parse the report const reportData = parseReport(content); // Validate the parsed data return validateData(reportData); } catch (error) { // Handle parsing errors const errors = []; if (error instanceof Error) { errors.push({ path: 'report', message: error.message, }); // If the error is a validation error, extract its details if ('errors' in error && Array.isArray(error.errors)) { error.errors.map((err) => { errors.push(err); }); } } else { errors.push({ path: 'report', message: 'Unknown error during report parsing or validation', }); } return { isValid: false, errors, }; } } //# sourceMappingURL=validate-report.js.map