Requires Node.js 24 or later; development and CI pin and test Node.js 24.18.0.
A TypeScript validation library for Protobuf messages using Spine Validation options, built on @bufbuild/protobuf (Protobuf-ES v2).
🔧 This library is in its experimental stage, the public API should not be considered stable.
This library lets you:
- ✅ Reuse the same validation rules in your frontend that you defined in your backend.
- ✅ Maintain a single source of truth — validation logic lives in your
.protofiles. - ✅ Keep frontend and backend validation in sync automatically.
- ✅ Get type-safe validation with full TypeScript support.
- ✅ Use error-message templates defined by the same Proto options.
Even if you're not using Spine Event Engine, this library provides a way to add runtime validation to your Protobuf-based TypeScript applications:
- ✅ Define validation in
.protofiles using declarative Spine Validation options. - ✅ Type-safe, runtime validation for Protobuf messages.
- ✅ Clear, customizable error messages for better UX.
- ✅ Works with Protobuf-ES v2 and modern tooling.
Comprehensive Validation Support
(required)— Validate the supported Proto-defined presence targets.(pattern)— Regex validation for strings.(min)/(max)— Numeric bounds with inclusive/exclusive support.(range)— Bounded ranges with bracket notation(min..max].(distinct)— Enforce uniqueness in repeated fields.(validate)— Recursive nested message validation.(goes)— Field dependency constraints.(require)— Complex required field combinations with boolean logic.(choice)— Require that aoneofgroup has at least one field set.(when)— Validate Spine Time values against past/future bounds; copy the officialspine/time_options.protoand its required Spine Time Proto files unchanged onto the import path.
Developer Experience
- 🚀 Full TypeScript type safety.
- 📝 Custom error messages.
- 🧪 Comprehensive contract and regression tests.
- 📚 Extensive documentation.
- 🎨 Clean, readable error formatting.
(set_once)— Not currently supported. This option requires state tracking across multiple validations, which is outside the scope of single-message validation.(pattern)— Uses ECMAScriptRegExp; the official Proto documentation uses JavaPatternas its syntax baseline. See the package regular-expression limitation.
See the package guide, the development reference, the development guide, and the executable example.
@spine-event-engine/validation is not yet available from the public npm
registry. See the package guide for the API
and release status, or run the executable example
from this repository.
This repository is structured as a pnpm workspace:
validation-ts/
├── packages/
│ ├── validation/ # 📦 Main validation package
│ │ ├── src/ # Source code
│ │ ├── tests/ # Contract and regression tests
│ │ ├── proto/ # Official Spine and project Proto files
│ │ ├── docs/ # Repository-only development reference
│ │ └── README.md # Full package documentation
│ │
│ └── example/ # 🎯 Example project
│ ├── proto/ # Example proto files
│ ├── src/ # Example usage code
│ └── README.md # Example documentation
│
└── README.md # You are here
See the package-level README for consumer setup and API details. The development reference contains architecture, exact validation behavior, and local development notes.
# Clone the repository
git clone <repository-url>
cd validation-ts
# Install with the pinned pnpm release without installing a system shim
corepack pnpm install --frozen-lockfileOn a cold host, Corepack may need network access for the pinned pnpm release; a cold pnpm store may then download the packages in the committed lockfile.
# Run the complete local and CI quality gate
corepack pnpm verify| Command | Description |
|---|---|
corepack pnpm verify |
Run generation, typechecking, lint, format, coverage, docs, Proto, and package checks |
corepack pnpm build |
Build the package and example |
corepack pnpm test |
Run validation-package and executable-example Vitest tests |
corepack pnpm example |
Run the example project |
See the contribution guide for review and delivery practices, and the development guide for local setup, generated inputs, extension workflows, and verification.
Apache 2.0.
- Protobuf-ES — Protocol Buffers for ECMAScript
- Buf — Modern Protobuf tooling
Made with ❤️ for the Spine Event Engine ecosystem.