ProvenPin Install

js-yaml 5 config files validated with Zod 4: working versions (tested 2026-10-15)

Parse YAML app config with js-yaml, validate it with Zod 4 (including env defaults), and reject unknown keys or bad types with field errors.

passed3 passed · 0 failed2026-10-15 16:01 UTC
Status
passed
Last passed
2026-10-15 16:01 UTC
Tests
3 / 3
Language
TypeScript
Runtime
node v22.23.3
pinned versions5
js-yaml@5.4.3zod@4.6.7@types/node@26.6.5tsx@4.23.15@types/js-yaml@4.0.9
run it
npm install --no-audit --no-fund --ignore-scripts=false
npm test
test environment
node v22.23.3
linux 6.17.0-1022-azure
x64
runner: github-actions 38764699834

The code

Exactly the files that passed. Your agent can pull them with get_recipe("js-yaml-zod-config") (install), or see them on GitHub.

package.json
{
  "name": "js-yaml-zod-config",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node --import tsx --test test/*.test.ts"
  },
  "dependencies": {
    "js-yaml": "5.4.3",
    "zod": "4.6.7"
  },
  "devDependencies": {
    "@types/node": "26.6.5",
    "tsx": "4.23.15",
    "@types/js-yaml": "4.0.9"
  }
}
src/config.ts
import { load } from "js-yaml";
import { z } from "zod";

export const AppConfig = z.object({
  name: z.string().min(1),
  port: z.number().int().min(1).max(65535).default(3000),
  features: z.object({
    billing: z.boolean().default(false),
    beta: z.boolean().default(false),
  }).default({ billing: false, beta: false }),
  database: z.object({
    url: z.string().min(1),
    pool: z.number().int().positive().default(5),
  }),
});

export type AppConfig = z.infer<typeof AppConfig>;

export function loadConfig(source: string): AppConfig {
  const raw = load(source);
  return AppConfig.parse(raw);
}

export function safeLoadConfig(source: string) {
  const raw = load(source);
  const r = AppConfig.safeParse(raw);
  if (!r.success) return { ok: false as const, issues: z.flattenError(r.error).fieldErrors };
  return { ok: true as const, data: r.data };
}
test/config.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import { loadConfig, safeLoadConfig } from "../src/config.ts";

const good = `
name: provenpin
database:
  url: "sqlite://:memory:"
features:
  billing: true
`;

test("loads yaml with defaults", () => {
  const cfg = loadConfig(good);
  assert.equal(cfg.name, "provenpin");
  assert.equal(cfg.port, 3000);
  assert.equal(cfg.features.billing, true);
  assert.equal(cfg.features.beta, false);
  assert.equal(cfg.database.pool, 5);
});

test("rejects missing database", () => {
  const r = safeLoadConfig("name: x\n");
  assert.equal(r.ok, false);
  if (!r.ok) assert.ok(r.issues.database);
});

test("rejects bad types", () => {
  const r = safeLoadConfig("name: x\nport: nope\ndatabase:\n  url: u\n");
  assert.equal(r.ok, false);
});

Connect to ProvenPin

Add the free MCP server so your agent can pull this recipe and others like it. Same setup as the docs.

terminal
claude mcp add --transport http provenpin https://mcp.provenpin.com/mcp

Any other MCP client: Streamable HTTP at https://mcp.provenpin.com/mcp. No API key, no signup.