@tracepass/dpp-validate

中文文档
0.19.0发布于 2026/11/03Apache-2.0TypeScriptES Module构建来源已验证

Evaluate an EU Digital Product Passport against its category field-spec — a three-tier compliance verdict with regulation-cited findings. Pure functions, no third-party runtime dependencies.

原始使用文档
文档目录5 节
  1. Three tiers
  2. It will not pass what it could not check
  3. Not legal advice
  4. Battery identifier requirement (BAT-1)
  5. License
TracePass

@tracepass/dpp-validate

Evaluate an EU Digital Product Passport against its category field spec. Pure functions, no third-party runtime dependencies, 46 tests.

License Dependencies

Part of tracepass-open · Maintained by TracePass


Given a passport and the template for its product category, evaluateCompliance returns a three-tier verdict with findings that cite the article of EU law each one rests on. It reads no database, opens no socket, and consults no clock.

npm install @tracepass/dpp-validate @tracepass/dpp-schemas
import { evaluateCompliance } from "@tracepass/dpp-validate";

const result = evaluateCompliance(passport, batteryTemplate, "battery");

result.verdict;               // "compliant" | "compliant_with_warnings" | "incomplete"
result.critical;              // findings that block
result.warnings;              // findings that don't
result.conditionalCoverage;   // "evaluated" | "static-only"
result.checkedRules;          // ["static:required-fields", ..., "BAT-1", "CC-1"]

Three tiers

Static — required fields are present and approved, required economic operators are identified, values match their datatype, enum, pattern, and bounds.

Conditional — obligations that only fire under a condition. Battery carbon-footprint fields apply only to rechargeable batteries; CE-marking coherence triggers when a conformity status is recorded. Five categories carry these rules — battery, construction, electronics, steel and toys — plus one cross-cutting rule for every category.

Some obligations start on a date. The battery passport is mandatory from 18 February 2027 (Regulation (EU) 2023/1542 Art. 77(1)), so a missing passport identifier is a warning before that day and critical from it. The engine reads the date from an optional fourth argument, which defaults to now; pass one to evaluate as of a given day:

evaluateCompliance(passport, batteryTemplate, "battery", new Date("2027-02-18"));

Coverage — the engine reports whether it evaluated conditionals at all. For the other six categories conditionalCoverage is "static-only", so silence is never mistaken for a compliance claim.

It will not pass what it could not check

When the field that decides a conditional is absent, the result is an unverifiable_conditional warning naming what could not be determined — never a quiet pass:

{
  "type": "unverifiable_conditional",
  "ruleId": "BAT-1",
  "target": "batteryCategory",
  "article": "Art. 77(1)",
  "why": "Battery category isn't set, so battery-passport scope couldn't be evaluated.",
  "fix": "Set batteryCategory. Portable and SLI batteries are out of scope; LMT, EV and industrial >2 kWh require a battery passport."
}

The same principle governs the battery applicability gates: an unknown classifier shows the dependent field and warns. A mis-classified battery must never silently lose a legally-required field.

A compliant verdict means this passport satisfies the rules encoded here — not this product may be placed on the market. Delegated acts are still landing. Verify against EUR-Lex.

Battery identifier requirement (BAT-1)

The battery passport must carry a unique product identifier. Battery Regulation Art. 77(3) requires ISO/IEC 15459 until a delegated act replaces it with EN 18219. A GS1 Digital Link URI satisfies that requirement because GS1 is an ISO/IEC 15459 issuing agency. The BAT-1 fix text in findings explains this:

{
  "fix": "Provide identifier — an ISO/IEC 15459 unique identifier, e.g. a GS1 Digital Link URI
          (Battery Regulation Art. 77(3) requires ISO/IEC 15459 until a delegated act replaces
          it with EN 18219)."
}

Plain-language background on the rules encoded here:

License

Apache-2.0

版本与发布记录

@tracepass/dpp-validate 共发布 28 个版本,首次发布于 2026/07/20;过去 12 个月发布了 28 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.19.0latest2026/11/03今天
0.18.42026/10/303 天前
0.18.32026/10/303 天前
0.18.22026/10/304 天前
0.18.12026/10/304 天前
0.18.02026/10/295 天前

关于 @tracepass/dpp-validate 的常见问题

@tracepass/dpp-validate 是什么?

根据类别字段规范评估欧盟数字产品护照-根据法规引用的调查结果进行三层合规裁决。纯函数,没有第三方运行时依赖。

如何安装 @tracepass/dpp-validate?

在项目目录运行 npm install @tracepass/dpp-validate,或使用 pnpm add / yarn add / bun add。

@tracepass/dpp-validate 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@tracepass/dpp-validate 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@tracepass/dpp-validate 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@tracepass/dpp-validate 可以商用吗?

@tracepass/dpp-validate 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@tracepass/dpp-validate 还在维护吗?

最新版本 0.19.0 发布于 2026/11/03(今天);至今共发布 28 个版本,其中过去 12 个月发布了 28 个;首次发布于 2026/07/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。