Sample
zod 3.24.0
Verified sample for npm zod 3.24.0. The contract ran on node 22 · linux debian/x64 · docker and passed: z.object validates structured schema with nested…
sha256:6627298f7b636f9d9fe2d01ca36d0dc4b282e94806538ceef8ef9e7e24e51f8a
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
linux 24 · ubuntu · glibc 2.39 x64 npm
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-10 |
Case
HOW- Goal
- verify pkg:npm/zod@3.24.0
- Packages
- Created
- 2026-09-10T16:38:02Z
Contract
- z.object validates structured schema with nested primitive validators and defaults
- z.string validates constraints including email and min length
- z.number validates integer and non-negative constraints
- z.enum validates allowed string literal choices and defaults
- z.coerce converts string input to typed numbers and booleans
- z.array and z.record validate collection structures
- safeParse returns structured validation issues on invalid payload
- refine and transform apply custom predicate validations and data transformations
- direct access to zod schema constructor functions
Files
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Source
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:npm/zod@3.24.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/zod@3.24.0
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:2f36c463d1e0c6e432dba2b8d4e6935f0f2451164a576fec70c2c8a7f37f8997","contract":["z.object validates structured schema with nested primitive validators and defaults","z.string validates constraints including email and min length","z.number validates integer and non-negative constraints","z.enum validates allowed string literal choices and defaults","z.coerce converts string input to typed numbers and booleans","z.array and z.record validate collection structures","safeParse returns structured validation issues on invalid payload","refine and transform apply custom predicate validations and data transformations","direct access to zod schema constructor functions"],"goal":"verify pkg:npm/zod@3.24.0","kind":"HOW","packages":["pkg:npm/zod@3.24.0"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/zod@3.24.0"],"schemaVersion":1,"subject":"pkg:npm/zod@3.24.0","verifierAdapter":"node-typescript@1"}
import { z } from 'zod';
export const userSchema = z.object({
id: z.string().min(1),
name: z.string().min(1).max(50),
age: z.number().int().nonnegative(),
email: z.string().email(),
role: z.enum(['admin', 'member', 'guest']).default('guest'),
isActive: z.boolean().default(true),
tags: z.array(z.string()).default([]),
metadata: z.record(z.string(), z.string()).optional(),
});
export const configSchema = z.object({
port: z.coerce.number().int().min(1).max(65535),
host: z.string().min(1),
debug: z.coerce.boolean().default(false),
timeoutMs: z.coerce.number().positive().default(5000),
});
export const passwordResetSchema = z
.object({
newPassword: z.string().min(8),
confirmPassword: z.string().min(8),
})
.refine((data) => data.newPassword === data.confirmPassword, {
message: 'Passwords must match',
path: ['confirmPassword'],
});
export const trimmedLowercaseSchema = z
.string()
.trim()
.toLowerCase()
.transform((val) => `user_${val}`);
export function parseUser(input) {
return userSchema.parse(input);
}
export function safeParseUser(input) {
return userSchema.safeParse(input);
}
export function parseConfig(input) {
return configSchema.parse(input);
}
export function safeParseConfig(input) {
return configSchema.safeParse(input);
}
export function validatePasswordReset(input) {
return passwordResetSchema.safeParse(input);
}
export function transformUsername(input) {
return trimmedLowercaseSchema.parse(input);
}
export { z };
{
"name": "sample-zod",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-zod",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"zod": "3.24.0"
}
},
"node_modules/zod": {
"version": "3.24.0",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.24.0.tgz",
"integrity": "sha512-Hz+wiY8yD0VLA2k/+nsg2Abez674dDGTai33SwNvMPuf9uIrBC9eFgIMQxBBbHFxVXi8W+5nX9DcAh9YNSQm/w==",
"license": "MIT"
}
}
}
{
"name": "sample-zod",
"version": "1.0.0",
"type": "module",
"private": true,
"description": "verify pkg:npm/zod@3.24.0",
"license": "MIT-0",
"dependencies": {
"zod": "3.24.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/zod@3.24.0",
"kind": "HOW",
"packages": [
"pkg:npm/zod@3.24.0"
]
}
import assert from 'node:assert/strict';
import {
z,
userSchema,
configSchema,
passwordResetSchema,
trimmedLowercaseSchema,
parseUser,
safeParseUser,
parseConfig,
safeParseConfig,
validatePasswordReset,
transformUsername,
} from '../index.mjs';
function runTests() {
// 1. z.object validates structured schema with nested primitive validators and defaults
{
const input = {
id: 'usr_1001',
name: 'Test User',
age: 30,
email: 'user@example.com',
};
const user = parseUser(input);
assert.equal(user.id, 'usr_1001');
assert.equal(user.name, 'Test User');
assert.equal(user.age, 30);
assert.equal(user.email, 'user@example.com');
assert.equal(user.role, 'guest');
assert.equal(user.isActive, true);
assert.deepEqual(user.tags, []);
}
// 2. z.string validates constraints including email and min length
{
const invalidEmail = safeParseUser({
id: 'usr_1002',
name: 'User',
age: 25,
email: 'not-an-email',
});
assert.equal(invalidEmail.success, false);
assert.ok(
invalidEmail.error.issues.some((issue) => issue.path.includes('email')),
'reports invalid email issue'
);
const emptyName = safeParseUser({
id: 'usr_1002',
name: '',
age: 25,
email: 'user@example.com',
});
assert.equal(emptyName.success, false);
assert.ok(
emptyName.error.issues.some((issue) => issue.path.includes('name')),
'reports empty name issue'
);
}
// 3. z.number validates integer and non-negative constraints
{
const negativeAge = safeParseUser({
id: 'usr_1003',
name: 'User',
age: -5,
email: 'user@example.com',
});
assert.equal(negativeAge.success, false);
assert.ok(
negativeAge.error.issues.some((issue) => issue.path.includes('age')),
'reports negative age issue'
);
const floatAge = safeParseUser({
id: 'usr_1003',
name: 'User',
age: 25.4,
email: 'user@example.com',
});
assert.equal(floatAge.success, false);
assert.ok(
floatAge.error.issues.some((issue) => issue.path.includes('age')),
'reports float age issue'
);
}
// 4. z.enum validates allowed string literal choices and defaults
{
const adminUser = parseUser({
id: 'usr_1004',
name: 'Admin',
age: 40,
email: 'admin@example.com',
role: 'admin',
});
assert.equal(adminUser.role, 'admin');
const invalidRole = safeParseUser({
id: 'usr_1004',
name: 'Admin',
age: 40,
email: 'admin@example.com',
role: 'superadmin',
});
assert.equal(invalidRole.success, false);
assert.ok(
invalidRole.error.issues.some((issue) => issue.path.includes('role')),
'reports invalid enum issue'
);
}
// 5. z.coerce converts string input to typed numbers and booleans
{
const config = parseConfig({
port: '8080',
host: 'localhost',
debug: 'true',
timeoutMs: '3000',
});
assert.equal(config.port, 8080);
assert.equal(typeof config.port, 'number');
assert.equal(config.host, 'localhost');
assert.equal(config.debug, true);
assert.equal(typeof config.debug, 'boolean');
assert.equal(config.timeoutMs, 3000);
const outOfRange = safeParseConfig({
port: '70000',
host: 'localhost',
});
assert.equal(outOfRange.success, false);
assert.ok(
outOfRange.error.issues.some((issue) => issue.path.includes('port')),
'reports port out of range'
);
}
// 6. z.array and z.record validate collection structures
{
const userWithCollections = parseUser({
id: 'usr_1005',
name: 'User',
age: 22,
email: 'user@example.com',
tags: ['developer', 'nodejs'],
metadata: { env: 'production', tier: 'standard' },
});
assert.deepEqual(userWithCollections.tags, ['developer', 'nodejs']);
assert.deepEqual(userWithCollections.metadata, { env: 'production', tier: 'standard' });
const invalidTags = safeParseUser({
id: 'usr_1005',
name: 'User',
age: 22,
email: 'user@example.com',
tags: ['valid', 999],
});
assert.equal(invalidTags.success, false);
}
// 7. safeParse returns structured validation issues on invalid payload
{
const res = safeParseUser({});
assert.equal(res.success, false);
assert.ok(Array.isArray(res.error.issues));
assert.ok(res.error.issues.length >= 3, 'reports multiple missing field issues');
assert.equal(res.error.name, 'ZodError');
}
// 8. refine and transform apply custom predicate validations and data transformations
{
const matchingPasswords = validatePasswordReset({
newPassword: 'securepassword123',
confirmPassword: 'securepassword123',
});
assert.equal(matchingPasswords.success, true);
const mismatchingPasswords = validatePasswordReset({
newPassword: 'securepassword123',
confirmPassword: 'differentpassword123',
});
assert.equal(mismatchingPasswords.success, false);
assert.ok(
mismatchingPasswords.error.issues.some((issue) => issue.path.includes('confirmPassword')),
'reports refine validation failure on confirmPassword'
);
const transformed = transformUsername(' sample_user ');
assert.equal(transformed, 'user_sample_user');
}
// 9. direct access to zod schema constructor functions
{
assert.equal(typeof z.object, 'function');
assert.equal(typeof z.string, 'function');
assert.equal(typeof z.number, 'function');
assert.equal(typeof z.boolean, 'function');
assert.equal(typeof z.array, 'function');
assert.equal(typeof z.record, 'function');
assert.equal(typeof z.enum, 'function');
assert.equal(typeof z.coerce, 'object');
}
console.log('Contract tests passed successfully.');
}
runTests();
Origin Seeder
anonymous