@cmsgov/hpt-validator-cli

中文文档
1.12.0发布于 2026/10/26CC0-1.0TypeScriptES Module构建来源已验证近 30 天下载 4393

CLI for validating CMS Hospital Price Transparency machine-readable files

原始使用文档
文档目录13 节
  1. Getting Started
  2. Prerequisites
  3. Installation
  4. Usage
  5. Data Dictionary Versions
  6. Examples
  7. Output Formats
  8. Machine-readable File Extensions
  9. Limitations
  10. Contributing
  11. Security
  12. Authors and Maintainers
  13. Public domain

Hospital Price Transparency CLI Validator

Version

CLI for validating CMS Hospital Price Transparency machine-readable files

Getting Started

Prerequisites

These were the minimum versions used to develop the CLI tool. It is recommended to keep both Node and NPM up-to-date with the latest releases.

  • Node (version 20.x)
  • NPM (version 8.5.x)

Installation

Install the CLI globally with

npm install -g @cmsgov/hpt-validator-cli

Usage

cms-hpt-validator --help
Usage: cms-hpt-validator [options] <filepath> <version>

Arguments:
  filepath                   filepath to validate
  version                    version of data dictionary requirements to validate against (choices: "v2.1", "v2.2", "v3.0")

Options:
  -V, --version              output the CLI version number
  -f, --format <string>      file format of file (choices: "csv", "json")
  -o, --output <string>      output format (choices: "table", "json", default: "table")
  -e, --error-limit <value>  maximum number for errors (default: 1000)
  -h, --help                 display help for command

Data Dictionary Versions

Refer to the Hospital Price Transparency Data Dictionary Repository for documentation of all requirement versions.

Examples

Basic usage:

cms-hpt-validator ./sample.csv v3.0

Overriding the default error limit to show 50 errors:

cms-hpt-validator ./sample.csv v3.0 -e 50

Overriding the default error limit to show all errors:

cms-hpt-validator ./sample.csv v3.0 -e 0

Using JSON output format:

cms-hpt-validator ./sample.csv v3.0 -o json

Using JSON output format with limited errors:

cms-hpt-validator ./sample.csv v3.0 -o json -e 10

Output Formats

The CLI supports two output formats:

Table Format (default)

The default table format provides a human-readable output with colored text, showing validation results in a structured table format.

JSON Format

The JSON format provides machine-readable output that includes:

  • File information (path, validator version, timestamp)
  • Validation status (valid/invalid)
  • Error and alert counts
  • Detailed error and alert arrays

Example JSON output:

{
  "file": "/path/to/sample.csv",
  "version": "1.10.0",
  "timestamp": "2025-01-11T17:00:00.000Z",
  "valid": false,
  "errorCount": 2,
  "alertCount": 1,
  "errors": [
    {
      "path": "C4",
      "field": "code | 1 | type",
      "message": "Invalid code type"
    }
  ],
  "alerts": [
    {
      "path": "D5",
      "field": "estimated_amount",
      "message": "Nine 9s used for estimated amount"
    }
  ]
}

Machine-readable File Extensions

The two current allowable file formats for the HPT MRFs are CSV and JSON. The CLI will auto detect the file format passed into the tool for files that end with .csv or .json and will run the appropriate validator for that file. The CLI can also detect files compressed by gzip. Files ending with the .gz extension will be decompressed before validation. These file format detections can be combined, so files ending with .csv.gz or .json.gz will be decompressed and validated as CSV or JSON, respectively. For other files ending with .gz, use the -f option described above.

Limitations

There may be a situation in which the CLI tool will run out of memory due to the amount of errors that are found in the file being validated. If you run into this NODE error, update the amount of errors to a smaller value that will be allowed to be collected with the -e, --error-limit flag.

Contributing

Thank you for considering contributing to an Open Source project of the US Government! For more information about our contribution guidelines, see CONTRIBUTING.md

Security

For more information about our Security, Vulnerability, and Responsible Disclosure Policies, see SECURITY.md.

Authors and Maintainers

A full list of contributors can be found on https://github.cms.gov/CMSGov/hpt-validator-cli/graphs/contributors.

Public domain

This project is licensed within in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.

All contributions to this project will be released under the CC0 dedication. By submitting a pull request or issue, you are agreeing to comply with this waiver of copyright interest.

版本与发布记录

@cmsgov/hpt-validator-cli 共发布 13 个版本,首次发布于 2025/07/25;过去 12 个月发布了 11 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.12.0latest2026/10/2614 天前
1.11.02026/10/2614 天前
1.10.82026/08/192 个月前
1.10.72026/06/035 个月前
1.10.62026/04/296 个月前
1.10.52026/04/097 个月前

关于 @cmsgov/hpt-validator-cli 的常见问题

@cmsgov/hpt-validator-cli 是什么?

CLI for validating CMS Hospital Price Transparency machine-readable files

如何安装 @cmsgov/hpt-validator-cli?

在项目目录运行 npm install @cmsgov/hpt-validator-cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 cms-hpt-validator,可以用 npx cms-hpt-validator 直接运行。

@cmsgov/hpt-validator-cli 支持 TypeScript 吗?

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

@cmsgov/hpt-validator-cli 支持 ESM 还是 CommonJS?

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

@cmsgov/hpt-validator-cli 可以商用吗?

@cmsgov/hpt-validator-cli 使用 CC0-1.0 许可。作者放弃著作权,可不受限制地使用。以上为概括,不构成法律意见,请以许可原文为准。

@cmsgov/hpt-validator-cli 的下载量有多少?

根据 npm 官方下载统计,@cmsgov/hpt-validator-cli 在 2026/10/10 – 2026/11/08 这 30 天内被下载 4,393 次,日均约 146 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cmsgov/hpt-validator-cli 还在维护吗?

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