Examples
Node.js — Validate an IMF package
Section titled “Node.js — Validate an IMF package”This example validates a local IMF package using @imferno/node, configures custom rule overrides with typed code constants, and prints the results.
npm install @imferno/nodeimport { buildReportFromPath, formatReport, codes } from "@imferno/node";import { resolve } from "node:path";
const impPath = resolve("./my-package");
const report = buildReportFromPath(impPath, { rules: { // Promote checksum mismatches to critical [codes.ST2067_2_2020.ChecksumMismatch]: "critical", // Suppress unreferenced asset warnings [codes.Imferno.UnreferencedAsset]: "off", },});
console.log("Compliant:", report.validation.is_compliant);console.log("Errors:", report.validation.errors.length);console.log("Warnings:", report.validation.warnings.length);
for (const issue of report.validation.errors) { console.log(` ${issue.code}: ${issue.message}`);}
// Pretty-print the full reportconsole.log(formatReport(report));
process.exit(report.validation.is_compliant ? 0 : 1);What’s happening
Section titled “What’s happening”-
buildReportFromPath(path, options?)reads an IMF package directory from disk, parses all XML files, and runs validation against every applicable SMPTE spec. -
codesgives you typed constants for all 250+ validation rules — autocomplete in your editor, no typos. -
report.validationcontainsis_compliant,errors,warnings,info, andcriticalarrays. Each issue has acode,message,severity, andlocation. -
formatReport(report)renders the report as a human-readable string, the same output asimferno reporton the CLI. -
The process exits with code 1 if the package is non-compliant, making it easy to use in CI pipelines.
See the Configuration page for all available options and the Validation Codes reference for the full rule catalogue.