npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dac7-validator

v0.1.2

Published

TypeScript validator for OECD DPI / EU DAC7 XML reports. Validates against the official XSD with typed, human-readable errors.

Downloads

340

Readme

dac7-validator

TypeScript validator for OECD DPI / EU DAC7 XML reports. Validates against the official XSD with typed, human-readable errors.

CI npm version license

Early pre-release (v0.1). API will change before 1.0. Today it covers XSD validation, typed errors, a CLI, and one jurisdiction-specific schematron rule (Swedish TIN). See the roadmap for what's coming.

Why

EU directive DAC7 forces digital platforms (marketplaces, rental, ride-share, gig) to report seller income to tax authorities annually. The required format is OECD's DPI XML Schema — and getting it wrong means fines up to €900k per filing.

Java and Python have decent tooling for this. Node/TypeScript did not. dac7-validator is the start of fixing that.

Install

npm install dac7-validator
# or
pnpm add dac7-validator

Requires Node 18+. Uses libxmljs2 (native dependency) for XSD validation.

Quick start

Library

import { validateDPI } from 'dac7-validator';
import { readFile } from 'node:fs/promises';

const xml = await readFile('./my-report.xml', 'utf-8');
const result = await validateDPI(xml, { jurisdiction: 'SE' });

if (!result.valid) {
  for (const err of result.errors) {
    console.error(`[${err.code}] ${err.path}: ${err.message}`);
    if (err.hint) console.error(`  hint: ${err.hint}`);
  }
}

CLI

npx dac7-validator validate ./my-report.xml
npx dac7-validator validate ./my-report.xml --jurisdiction SE --json

Exit code 0 if valid, 1 if not. Suitable for CI.

Error codes

Every error has a stable code and a documentation page:

| Code | Meaning | | --- | --- | | OECD_DPI_E000 | XML is not well-formed | | OECD_DPI_E001 | Element appears in wrong position | | OECD_DPI_E002 | Required child element missing | | OECD_DPI_E003 | Value does not match required type | | OECD_DPI_E004 | Value not in allowed code list | | OECD_DPI_E005 | Required attribute missing | | OECD_DPI_E006 | Unknown element | | OECD_DPI_E007 | Element not declared in schema | | OECD_DPI_E999 | Unmapped schema error | | OECD_DPI_S001 | Invalid Swedish TIN (schematron, jurisdiction=SE) | | OECD_DPI_S100 | MessageSpec missing MessageRefId (schematron) |

Codes prefixed E come from XSD validation; codes prefixed S come from schematron business rules.

Full catalog under docs/errors/.

Schema files

The official OECD DPI XML Schema v1.0 is bundled under schemas/oecd/. See schemas/oecd/README.md for source and attribution.

What's in v0.1

  • XSD validation against the official OECD DPI XML Schema v1.0 (bundled)
  • Typed ValidationResult and ValidationError with stable error codes
  • Per-error documentation pages with hints and broken-then-fixed examples
  • dac7-validator CLI (validate subcommand with --json and --jurisdiction)
  • Schematron infrastructure layered on top of XSD validation
  • First jurisdiction rule: Swedish TIN — OECD_DPI_S001 (Luhn check on org-nr / personnummer)
  • Public helpers isValidSwedishTIN() and luhn()

Roadmap

Planned for later releases. Not implemented yet — don't rely on these in v0.1:

  • More jurisdictions: DE, FR, NL, BE (note: FR uses a different schema namespace)
  • Full schematron compatibility — compile official OECD .sch files with Saxon-JS
  • Threshold-rule checks (<30 sales AND <€2000 for goods)
  • Correction-report (CorrDocRefId) flow validation
  • Builder API: buildDPIReport(data) → XML
  • TIN validation for more jurisdictions
  • Hosted browser playground

Track progress in the CHANGELOG and on the issue tracker.

Contributing

Issues and PRs welcome. If you hit OECD_DPI_E999 (unmapped schema error), please open an issue with the raw libxml message — we'll add a mapping. If you have access to country-specific schematron rules and example XML, that's especially valuable.

License

MIT — see LICENSE. The bundled OECD XSDs are © OECD; see schemas/oecd/README.md for terms.


Built by Fiive.