New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@cratestack/validator-zod

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cratestack/validator-zod

An RpcLink for CrateStack's generated TypeScript RPC client that validates request input against per-op zod schemas.

latest
Source
npmnpm
Version
0.15.4
Version published
Weekly downloads
176
70.87%
Maintainers
1
Weekly downloads
 
Created
Source

@cratestack/validator-zod

An RpcLink (issue #182) for CrateStack's generated TypeScript RPC client (transport rpc schemas) that validates request.input against a per-op zod schema before the call reaches the network — client-side validation with the exact same schema shape your server-side procedure/model input already has, instead of hoping the generated types alone catch a bad call at compile time.

Usage

import { createZodValidatorLink } from "@cratestack/validator-zod";
import { CratestackRpcRuntime } from "./generated/runtime"; // your project's generated client
import { z } from "zod";

const runtime = new CratestackRpcRuntime("https://api.example.com", {
  links: [
    createZodValidatorLink({
      "model.Order.create": z.object({ total: z.number().positive() }),
    }),
  ],
});

Ops with no configured schema pass through unvalidated — this is opt-in per op, not a blanket gate. On success, the schema's parsed output (defaults, z.coerce, transforms) becomes the actual request input, not just a type-level assertion. On failure, the chain short-circuits — the real network call never happens — and the call rejects the same way a server-side validation failure would, with an RpcErrorBody carrying code: "invalid_argument".

Keywords

cratestack

FAQs

Package last updated on 11 Oct 2026

Related posts