Skip to content

feat: add Kosit external validator for UBL XML validation#7

Merged
SimonLoir merged 6 commits intomainfrom
copilot/add-kosit-validator
Mar 31, 2026
Merged

feat: add Kosit external validator for UBL XML validation#7
SimonLoir merged 6 commits intomainfrom
copilot/add-kosit-validator

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

Adds support for validating UBL XML documents against a Kosit validator service via HTTP POST.

Changes

  • src/validator/KositValidator.ts — Sends XML to Kosit endpoint, parses the XML report response to extract accept/reject status, errors, and warnings. Uses native fetch, no new dependencies.
  • src/index.ts — Exposes validateWithKosit(xml, options?) on PeppolToolkit; re-exports validator types.
  • tests/kosit-validator.test.ts — 10 tests covering accepted/rejected reports, warnings, error handling, custom endpoints.

Usage

const toolkit = new PeppolToolkit();
const xml = toolkit.invoiceToPeppolUBL(invoice);

// Uses default endpoint http://localhost:8081/
const result = await toolkit.validateWithKosit(xml);

// Or with custom endpoint
const result = await toolkit.validateWithKosit(xml, {
  endpoint: 'http://my-validator:9090/',
});

console.log(result.valid);    // boolean
console.log(result.errors);   // KositValidationMessage[]
console.log(result.warnings); // KositValidationMessage[]
console.log(result.rawXml);   // raw Kosit XML report

// Standalone usage
const validator = new KositValidator({ endpoint: 'http://localhost:8081/' });
const result = await validator.validate(xml);

@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Mar 31, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 26 complexity . 2 duplication

Metric Results
Complexity 26
Duplication 2

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

Copilot AI changed the title [WIP] Add validator using external KoSIT service feat: add Kosit external validator for UBL XML validation Mar 31, 2026
Copilot AI requested a review from SimonLoir March 31, 2026 20:21
@SimonLoir SimonLoir marked this pull request as ready for review March 31, 2026 21:02
@SimonLoir SimonLoir merged commit 89cd85a into main Mar 31, 2026
3 checks passed
@SimonLoir SimonLoir deleted the copilot/add-kosit-validator branch March 31, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants