UNPKG

@accounter/shaam6111-generator

Version:

Fully typed application that generates, parses, and validates SHAAM 6111 tax reports.

45 lines (44 loc) 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.validateReport = validateReport; const parse_report_js_1 = require("../parsers/parse-report.js"); const validate_data_js_1 = require("./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. */ function validateReport(content) { try { // Parse the report const reportData = (0, parse_report_js_1.parseReport)(content); // Validate the parsed data return (0, validate_data_js_1.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, }; } }