샘플
zod 4.1.12: z
검증된 샘플 — npm zod 4.1.12: z. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: z.object validates structured schema with nested primitive validators…
sha256:8b25af574b39d2d2e49ad18ef57ac04ea78980ff32a57adcbfa4f72cbfa64716
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-23 |
| 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-07 |
케이스
HOW- 목표
- verify zod.z in pkg:npm/zod@4.1.12
- 패키지
- 심벌
-
- zod.z
- 생성일
- 2026-08-23T05:38:36Z
컨트랙트
- 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 validates lists of elements
- safeParse returns structured validation issues on invalid payload
파일
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.js
소스
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 zod.z in pkg:npm/zod@4.1.12
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/zod@4.1.12
Demonstrate these symbols/APIs:
- zod.z
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:9a770d701dbe0d4606a127538f05f507b6ba6e039254d1c022ed0cca3489b505","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 validates lists of elements","safeParse returns structured validation issues on invalid payload"],"goal":"verify zod.z in pkg:npm/zod@4.1.12","kind":"HOW","packages":["pkg:npm/zod@4.1.12"],"schemaVersion":1,"symbols":["zod.z"]},"contractCommand":["node","test/contract.js"],"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@4.1.12"],"schemaVersion":1,"subject":"pkg:npm/zod@4.1.12","symbols":["zod.z"],"verifierAdapter":"node-typescript@1"}
const { z } = require('zod');
// Schema for user profiles demonstrating primitives, object, enum, defaults, and constraints
const userSchema = z.object({
id: z.string().min(1),
name: z.string().min(1),
age: z.number().int().nonnegative(),
email: z.string().email(),
role: z.enum(['admin', 'user', 'guest']).default('user'),
isActive: z.boolean().default(true),
tags: z.array(z.string()).default([]),
});
// Schema demonstrating coercion and range bounds
const configSchema = z.object({
port: z.coerce.number().int().min(1).max(65535),
host: z.string().min(1),
debug: z.coerce.boolean().default(false),
});
function parseUser(input) {
return userSchema.parse(input);
}
function safeParseUser(input) {
return userSchema.safeParse(input);
}
function parseConfig(input) {
return configSchema.parse(input);
}
function safeParseConfig(input) {
return configSchema.safeParse(input);
}
module.exports = {
z,
userSchema,
configSchema,
parseUser,
safeParseUser,
parseConfig,
safeParseConfig,
};
{
"name": "sample-zod",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-zod",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"zod": "4.1.12"
}
},
"node_modules/zod": {
"version": "4.1.12",
"resolved": "https://registry.npmjs.org/zod/-/zod-4.1.12.tgz",
"integrity": "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
}
}
}
{
"name": "sample-zod",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification sample for zod.z in zod",
"main": "index.js",
"scripts": {
"test": "node test/contract.js"
},
"license": "MIT-0",
"dependencies": {
"zod": "4.1.12"
}
}
{
"schemaVersion": 1,
"goal": "verify zod.z in pkg:npm/zod@4.1.12",
"kind": "HOW",
"packages": [
"pkg:npm/zod@4.1.12"
],
"symbols": [
"zod.z"
]
}
const assert = require('assert');
const {
z,
userSchema,
configSchema,
parseUser,
safeParseUser,
parseConfig,
safeParseConfig,
} = require('../index.js');
function runTests() {
// 1. z.object validates structured schema with nested primitive validators and defaults
{
const input = {
id: 'usr_123',
name: 'Alice',
age: 28,
email: 'alice@example.com',
};
const user = parseUser(input);
assert.strictEqual(user.id, 'usr_123');
assert.strictEqual(user.name, 'Alice');
assert.strictEqual(user.age, 28);
assert.strictEqual(user.email, 'alice@example.com');
assert.strictEqual(user.role, 'user', 'applies default role');
assert.strictEqual(user.isActive, true, 'applies default isActive');
assert.deepStrictEqual(user.tags, [], 'applies default empty tags array');
}
// 2. z.string validates constraints including email and min length
{
const invalidEmail = safeParseUser({
id: 'usr_123',
name: 'Alice',
age: 28,
email: 'not-a-valid-email',
});
assert.strictEqual(invalidEmail.success, false);
assert.ok(
invalidEmail.error.issues.some((issue) => issue.path.includes('email')),
'reports invalid email issue'
);
const emptyName = safeParseUser({
id: 'usr_123',
name: '',
age: 28,
email: 'alice@example.com',
});
assert.strictEqual(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_123',
name: 'Alice',
age: -1,
email: 'alice@example.com',
});
assert.strictEqual(negativeAge.success, false);
assert.ok(
negativeAge.error.issues.some((issue) => issue.path.includes('age')),
'reports negative age issue'
);
const floatAge = safeParseUser({
id: 'usr_123',
name: 'Alice',
age: 28.5,
email: 'alice@example.com',
});
assert.strictEqual(floatAge.success, false);
assert.ok(
floatAge.error.issues.some((issue) => issue.path.includes('age')),
'reports non-integer age issue'
);
}
// 4. z.enum validates allowed string literal choices and defaults
{
const validRole = parseUser({
id: 'usr_456',
name: 'Bob',
age: 35,
email: 'bob@example.com',
role: 'admin',
});
assert.strictEqual(validRole.role, 'admin');
const invalidRole = safeParseUser({
id: 'usr_456',
name: 'Bob',
age: 35,
email: 'bob@example.com',
role: 'superadmin',
});
assert.strictEqual(invalidRole.success, false);
assert.ok(
invalidRole.error.issues.some((issue) => issue.path.includes('role')),
'reports invalid enum value issue'
);
}
// 5. z.coerce converts string input to typed numbers and booleans
{
const config = parseConfig({
port: '8080',
host: 'localhost',
debug: 'true',
});
assert.strictEqual(config.port, 8080);
assert.strictEqual(typeof config.port, 'number');
assert.strictEqual(config.host, 'localhost');
assert.strictEqual(config.debug, true);
assert.strictEqual(typeof config.debug, 'boolean');
const outOfRange = safeParseConfig({
port: '99999',
host: 'localhost',
});
assert.strictEqual(outOfRange.success, false);
assert.ok(
outOfRange.error.issues.some((issue) => issue.path.includes('port')),
'reports port out of range issue'
);
}
// 6. z.array validates lists of elements
{
const userWithTags = parseUser({
id: 'usr_789',
name: 'Charlie',
age: 22,
email: 'charlie@example.com',
tags: ['developer', 'tester'],
});
assert.deepStrictEqual(userWithTags.tags, ['developer', 'tester']);
const invalidTags = safeParseUser({
id: 'usr_789',
name: 'Charlie',
age: 22,
email: 'charlie@example.com',
tags: ['valid', 123],
});
assert.strictEqual(invalidTags.success, false);
}
// 7. safeParse returns structured validation issues on invalid payload
{
const res = safeParseUser({});
assert.strictEqual(res.success, false);
assert.ok(Array.isArray(res.error.issues));
assert.ok(res.error.issues.length >= 3, 'multiple missing field issues reported');
}
// 8. Direct access to zod.z exports
{
assert.strictEqual(typeof z.object, 'function');
assert.strictEqual(typeof z.string, 'function');
assert.strictEqual(typeof z.number, 'function');
assert.strictEqual(typeof z.boolean, 'function');
assert.strictEqual(typeof z.array, 'function');
assert.strictEqual(typeof z.enum, 'function');
assert.strictEqual(typeof z.coerce, 'object');
}
console.log('Contract tests passed successfully.');
}
runTests();
오리진 시더
익명