# @codaco/protocol-validation

> Utilities for validating and migrating Network Canvas protocol files.

Latest version **13.0.1** (published 2026-09-02) · GPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @codaco/protocol-validation
pnpm add @codaco/protocol-validation
yarn add @codaco/protocol-validation
bun add @codaco/protocol-validation
```

Provides the command `@codaco/protocol-validation`.

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 13.0.1 |
| Published | 2026-09-02 |
| First published | 2023-10-09 |
| Weekly downloads | 0 |
| License | GPL-3.0-or-later |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 1.9 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2 |
| Author | Complex Data Collective <hello@complexdatacollective.org> |
| Maintainers | jthrilly, buckhalt |

## Links

- npm: https://www.npmjs.com/package/@codaco/protocol-validation
- Repository: https://github.com/complexdatacollective/network-canvas-monorepo
- npm.io page: https://npm.io/package/@codaco/protocol-validation

## Dependencies (3)

- [zod](https://npm.io/package/zod.md) ^4.4.3
- [ohash](https://npm.io/package/ohash.md) ^2.0.11
- [@codaco/shared-consts](https://npm.io/package/@codaco/shared-consts.md) ^6.0.0

## Recent versions

- 13.0.1 (latest) — 2026-09-02
- 11.4.0-alpha.0 (alpha) — 2026-04-20
- 13.0.0 — 2026-08-31
- 12.1.1 — 2026-08-11
- 12.1.0 — 2026-07-31
- 12.0.0 — 2026-07-29
- 11.12.0 — 2026-07-23
- 11.11.0 — 2026-07-20
- 11.10.0 — 2026-07-16
- 11.9.0 — 2026-07-15
- 11.8.1 — 2026-07-06
- 11.8.0 — 2026-07-03
- 11.7.0 — 2026-06-26
- 11.6.1 — 2026-06-01
- 11.6.0 — 2026-05-20
- … 38 more at https://npm.io/package/@codaco/protocol-validation/versions

## README

# @codaco/protocol-validation

This npm package implements methods for validating Network Canvas protocol files against an appropriate JSON schema.

It exports three primary methods for protocol validation:

1. validateSchema - validates a schema against the JSON schema

```js
const { hasErrors, errors } = validateSchema(schemaJson);
```

2. validateLogic - validates the logic of the protocol to ensure there are no inconsistencies. This includes validations that cannot be implemented within the JSON schema.

```js
const { hasErrors, errors } = validateLogic(protocolJson);
```

3. validateProtocol - validates the protocol against the schema and logic.

```js
const result = await validateProtocol(protocolJson);
if (result.success) {
  // protocol is valid, validated data available in result.data
} else {
  // protocol is invalid
  // result.error contains the Zod error
  console.error(result.error);
}
```

It also exports several utility methods for managing protocol validation.

1. migrateProtocol - migrates protocols from one version to another

```js
const migratedProtocol = migrateProtocol(8, protocolJson);
```

2. canUpgrade - checks if protocol can be upgraded from one schema version to another

```js
const canProtocolUpgrade = canUpgrade(7, 8);
```

3. getMigrationNotes - returns migration notes on the changes between a source schema version and a target schema version.

```js
const migrationNotes = getMigrationNotes(7, 8);
```

4. getVariableNamesFromNetwork - returns variable names from an external network data source

```js
const variableNames = getVariableNamesFromNetwork(network);
```

5. validateNames - validates variable names to ensure they only contain letters, numbers, and the symbols .\_-:

```js
const validationResult = validateNames(variableNamesArray);
```

---
_Source: https://npm.io/package/@codaco/protocol-validation · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
