# protodef-validator

> Validate ProtoDef protocol definition in node

Latest version **1.5.0** (published 2026-08-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install protodef-validator
pnpm add protodef-validator
yarn add protodef-validator
bun add protodef-validator
```

Provides the command `protodef-validator`.

## Health

**Score 60/100 (C)** — status: active.

Positive: no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.5.0 |
| Published | 2026-08-27 |
| First published | 2017-02-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 71.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Author | Romain Beaumont |
| Maintainers | rom1504 |
| Keywords | protodef, type, serialization, schema, json |

## Links

- npm: https://www.npmjs.com/package/protodef-validator
- Repository: https://github.com/ProtoDef-io/node-protodef-validator
- Homepage: https://github.com/ProtoDef-io/node-protodef-validator#readme
- Issues: https://github.com/ProtoDef-io/node-protodef-validator/issues
- npm.io page: https://npm.io/package/protodef-validator

## Dependencies (1)

- [ajv](https://npm.io/package/ajv.md) ^6.5.4

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.5.0 (latest) — 2026-08-27
- 1.4.0 — 2024-12-09
- 1.3.1 — 2021-06-10
- 1.3.0 — 2021-06-09
- 1.2.3 — 2019-08-24
- 1.2.2 — 2018-09-24
- 1.2.1 — 2018-09-24
- 1.2.0 — 2018-01-01
- 1.1.7 — 2017-02-26
- 1.1.6 — 2017-02-26
- 1.1.5 — 2017-02-26
- 1.1.4 — 2017-02-26
- 1.1.3 — 2017-02-26
- 1.1.2 — 2017-02-26
- 1.1.0 — 2017-02-09
- … 3 more at https://npm.io/package/protodef-validator/versions

## README

# ProtoDef-validator

[![NPM version](https://img.shields.io/npm/v/protodef-validator.svg)](http://npmjs.com/package/protodef-validator)
[![Discord](https://img.shields.io/badge/chat-on%20discord-brightgreen.svg)](https://discord.gg/GsEFRM8)
[![Gitter](https://img.shields.io/badge/chat-on%20gitter-brightgreen.svg)](https://gitter.im/PrismarineJS/general)
[![Irc](https://img.shields.io/badge/chat-on%20irc-brightgreen.svg)](https://irc.gitter.im/)
[![Build Status](https://github.com/ProtoDef-io/node-protodef-validator/workflows/CI/badge.svg)](https://github.com/ProtoDef-io/node-protodef-validator/actions?query=workflow%3A%22CI%22)
[![Try it on gitpod](https://img.shields.io/badge/try-on%20gitpod-brightgreen.svg)](https://gitpod.io/#https://github.com/ProtoDef-io/node-protodef-validator)


Validate [ProtoDef](https://github.com/ProtoDef-io/ProtoDef) protocol definition in node

## Installing

```
npm install protodef-validator
```

## Usage

See [example](example.js)

## Command Line Interface

You can install this package globally with `npm install -g protodef-validator` and then run `protodef-validator someProtocol.json` to validate it.

## API

### Validator

Class to make validator instances

#### Validator.addType(name [,schema])

add the type `name` with schema `schema`

If `schema` isn't specified, use a default schema.

#### Validator.addTypes(schemas)

Add `schemas` which is an object with keys the name of the schemas and values the schema definitions.

#### Validator.validateType(type)

validates a type definition `type`

throws an exception if the type isn't correct

#### Validator.validateProtocol(protocol)

validates a protocol definition `protocol`

throws an exception if the protocol isn't correct

## History

### 1.5.0
* [Speed up dataType validation ~12x by collapsing default type branches (#18)](https://github.com/ProtoDef-io/node-protodef-validator/commit/30c2075f2f3dd86e5fc0d748cc863eef42e80c3c) (thanks @u9g)
* [Fix publish condition for npm-publish v4 (#17)](https://github.com/ProtoDef-io/node-protodef-validator/commit/470e691e191261fe3d84a24249790f11d9f8d875) (thanks @rom1504)
* [Switch to trusted publishing via OIDC (#16)](https://github.com/ProtoDef-io/node-protodef-validator/commit/6080ed63d0791d470f4c2d0ef5d209431d5ff06b) (thanks @rom1504)

### 1.4.0
* [Create commands.yml (#14)](https://github.com/ProtoDef-io/node-protodef-validator/commit/3597c71d35a600c76438b2082782032ab40daa97) (thanks @extremeheat)
* [update submodule (#13)](https://github.com/ProtoDef-io/node-protodef-validator/commit/d79b1085a2590de5e33b811b777b16902134379b) (thanks @extremeheat)

### 1.3.0

* update protodef

### 1.2.3

* add .json suffix when requiring (for webpack)

### 1.2.2

* fix release

### 1.2.1

* update ajv and protodef

### 1.2.0

* allow : in switch keys

### 1.1.7

* properly define compareTo/compareToValue

### 1.1.6

* fix compareToValue switch property allowance

### 1.1.5

* properly normalize schema names

### 1.1.4

* normalize refs

### 1.1.3

* print errors again

### 1.1.2

* fix release

### 1.1.1

* recreate ajv instance to recompile if types were validated hence compiled

### 1.1.0

* check the datatypes have been defined
* make it possible to add types with a default schema
* better errors

### 1.0.2

* ignore already added types

### 1.0.1

* fix index.js

### 1.0.0

* can validate types and protocols

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