Skip to content
imferno

Examples

This example validates a local IMF package using @imferno/node, configures custom rule overrides with typed code constants, and prints the results.

Terminal window
npm install @imferno/node
import { 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 report
console.log(formatReport(report));
process.exit(report.validation.is_compliant ? 0 : 1);
  1. buildReportFromPath(path, options?) reads an IMF package directory from disk, parses all XML files, and runs validation against every applicable SMPTE spec.

  2. codes gives you typed constants for all 250+ validation rules — autocomplete in your editor, no typos.

  3. report.validation contains is_compliant, errors, warnings, info, and critical arrays. Each issue has a code, message, severity, and location.

  4. formatReport(report) renders the report as a human-readable string, the same output as imferno report on the CLI.

  5. 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.