ProvenPin Install

Valibot 1 pipes, transforms and branded outputs: working versions (tested 2026-10-15)

Build a Valibot 1 schema pipeline with trim, email, pipe transforms, brands and safeParse that returns typed output or issue paths, without a web framework.

passed4 passed · 0 failed2026-10-15 15:05 UTC
Status
passed
Last passed
2026-10-15 15:05 UTC
Tests
4 / 4
Language
TypeScript
Runtime
node v22.23.3
pinned versions3
valibot@1.5.0@types/node@26.6.5tsx@4.23.15
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 38755782594

The code

Exactly the files that passed. Your agent can pull them with get_recipe("valibot-transforms-pipeline") (install), or see them on GitHub.

package.json
{
  "name": "valibot-transforms-pipeline",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node --import tsx --test test/*.test.ts"
  },
  "dependencies": {
    "valibot": "1.5.0"
  },
  "devDependencies": {
    "@types/node": "26.6.5",
    "tsx": "4.23.15"
  }
}
src/schema.ts
import * as v from "valibot";

export const Email = v.pipe(v.string(), v.trim(), v.email(), v.toLowerCase());

export const UserId = v.pipe(
  v.string(),
  v.regex(/^usr_[a-z0-9]+$/),
  v.brand("UserId"),
);

export const CreateAccount = v.object({
  email: Email,
  displayName: v.pipe(v.string(), v.trim(), v.minLength(2), v.maxLength(40)),
  age: v.optional(v.pipe(v.number(), v.integer(), v.minValue(13)), 18),
  tags: v.optional(v.pipe(v.array(v.pipe(v.string(), v.trim(), v.minLength(1))), v.maxLength(5)), []),
});

export type CreateAccountInput = v.InferInput<typeof CreateAccount>;
export type CreateAccountOutput = v.InferOutput<typeof CreateAccount>;

export function parseAccount(input: unknown) {
  const r = v.safeParse(CreateAccount, input);
  if (!r.success) {
    return {
      ok: false as const,
      issues: r.issues.map((i) => ({ path: i.path?.map((p) => p.key).join(".") ?? "", message: i.message })),
    };
  }
  return { ok: true as const, data: r.output };
}
test/schema.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import * as v from "valibot";
import { Email, UserId, parseAccount } from "../src/schema.ts";

test("normalizes email", () => {
  assert.equal(v.parse(Email, "  [email protected] "), "[email protected]");
});

test("brands user ids", () => {
  const id = v.parse(UserId, "usr_abc");
  assert.equal(id, "usr_abc");
  assert.throws(() => v.parse(UserId, "abc"));
});

test("parses account with defaults", () => {
  const r = parseAccount({ email: " [email protected] ", displayName: "  Ada  " });
  assert.equal(r.ok, true);
  if (r.ok) {
    assert.equal(r.data.email, "[email protected]");
    assert.equal(r.data.displayName, "Ada");
    assert.equal(r.data.age, 18);
    assert.deepEqual(r.data.tags, []);
  }
});

test("reports issue paths", () => {
  const r = parseAccount({ email: "nope", displayName: "x" });
  assert.equal(r.ok, false);
  if (!r.ok) {
    assert.ok(r.issues.some((i) => i.path === "email"));
    assert.ok(r.issues.some((i) => i.path === "displayName"));
  }
});

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.