샘플
@eslint/object-schema 2.1.7: ObjectSchema
검증된 샘플 — npm @eslint/object-schema 2.1.7: ObjectSchema. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: ObjectSchema validates object properties…
sha256:5af35377f5507a61cd10ccb268c556f0d656dcefcf126539981a838e1b8af6a9
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 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-28 |
케이스
HOW- 목표
- verify pkg:npm/%40eslint/object-schema@2.1.7
- 심벌
-
- ObjectSchema
- 생성일
- 2026-08-28T05:27:34Z
컨트랙트
- ObjectSchema validates object properties against built-in validation strategies and throws errors on unexpected keys, missing required keys, or invalid types
- ObjectSchema enforces dependent property requirements specified by the requires array
- ObjectSchema supports custom validation and merge functions and ignores key updates when merge strategy returns undefined
- ObjectSchema merges multiple objects using built-in merge strategies assign, overwrite, and replace
- ValidationStrategy and MergeStrategy static methods correctly validate primitive and complex types and execute merge algorithms
파일
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
소스
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/%40eslint/object-schema@2.1.7
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40eslint/object-schema@2.1.7
Demonstrate these symbols/APIs:
- ObjectSchema
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:f2439122b2c596193cedc713cadd304f39015311aa9e92050043f3d7d7867dfb","contract":["ObjectSchema validates object properties against built-in validation strategies and throws errors on unexpected keys, missing required keys, or invalid types","ObjectSchema enforces dependent property requirements specified by the requires array","ObjectSchema supports custom validation and merge functions and ignores key updates when merge strategy returns undefined","ObjectSchema merges multiple objects using built-in merge strategies assign, overwrite, and replace","ValidationStrategy and MergeStrategy static methods correctly validate primitive and complex types and execute merge algorithms"],"goal":"verify pkg:npm/%40eslint/object-schema@2.1.7","kind":"HOW","packages":["pkg:npm/%40eslint/object-schema@2.1.7"],"schemaVersion":1,"symbols":["ObjectSchema"]},"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/%40eslint/object-schema@2.1.7"],"schemaVersion":1,"subject":"pkg:npm/%40eslint/object-schema@2.1.7","symbols":["ObjectSchema"],"verifierAdapter":"node-typescript@1"}
import { ObjectSchema, ValidationStrategy, MergeStrategy } from "@eslint/object-schema";
export function createConfigSchema(definitions) {
return new ObjectSchema(definitions);
}
export { ObjectSchema, ValidationStrategy, MergeStrategy };
{
"name": "sample-eslint-object-schema",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-eslint-object-schema",
"version": "1.0.0",
"dependencies": {
"@eslint/object-schema": "2.1.7"
}
},
"node_modules/@eslint/object-schema": {
"version": "2.1.7",
"resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.7.tgz",
"integrity": "sha512-VtAOaymWVfZcmZbp6E2mympDIHvyjXs/12LqWYjVw6qjrfF+VK+fyG33kChz3nnK+SU5/NeHOqrTEHS8sXO3OA==",
"license": "Apache-2.0",
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
}
}
}
}
{
"name": "sample-eslint-object-schema",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"@eslint/object-schema": "2.1.7"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/%40eslint/object-schema@2.1.7",
"kind": "HOW",
"packages": [
"pkg:npm/%40eslint/object-schema@2.1.7"
],
"symbols": [
"ObjectSchema"
]
}
import assert from "node:assert/strict";
import { ObjectSchema, ValidationStrategy, MergeStrategy } from "@eslint/object-schema";
// 1. ObjectSchema validates object properties against built-in validation strategies and throws errors on unexpected keys, missing required keys, or invalid types
const schema = new ObjectSchema({
id: {
required: true,
merge: "replace",
validate: "number"
},
name: {
required: true,
merge: "overwrite",
validate: "string!"
},
tag: {
required: false,
merge: "overwrite",
validate: "string"
},
flags: {
required: false,
merge: "assign",
validate: "object"
},
items: {
required: false,
merge: "overwrite",
validate: "array"
},
metadata: {
required: false,
merge: "replace",
validate: "object?"
},
enabled: {
required: false,
merge: "overwrite",
validate: "boolean"
},
secret: {
required: false,
requires: ["id"],
merge: "overwrite",
validate: "string"
},
custom: {
required: false,
merge(target, source) {
if (source === "ignore") return undefined;
if (target === undefined) return source;
return `${target}:${source}`;
},
validate(value) {
if (typeof value !== "string" || !value.startsWith("valid_")) {
throw new TypeError("custom must start with valid_");
}
}
},
nested: {
required: false,
merge: "assign",
validate: "object",
schema: {
subKey: {
required: false,
merge: "overwrite",
validate: "string"
}
}
}
});
// hasKey checks
assert.equal(schema.hasKey("id"), true);
assert.equal(schema.hasKey("name"), true);
assert.equal(schema.hasKey("nonexistent"), false);
// Valid object validation
assert.doesNotThrow(() => {
schema.validate({
id: 1,
name: "test-object",
tag: "v1",
flags: { a: 1 },
items: [1, 2, 3],
metadata: null,
enabled: true,
secret: "secret-key",
custom: "valid_value",
nested: {
subKey: "sub-value"
}
});
});
// Errors on unexpected keys
assert.throws(() => {
schema.validate({
id: 1,
name: "test-object",
unexpectedProperty: "bad"
});
}, /unexpected/i);
// Errors on missing required keys
assert.throws(() => {
schema.validate({
id: 1
});
}, /Missing required key/i);
// Errors on invalid types
assert.throws(() => {
schema.validate({
id: "not-a-number",
name: "test-object"
});
}, /Expected a number/i);
// Empty string for string! fails
assert.throws(() => {
schema.validate({
id: 1,
name: ""
});
}, /Expected a non-empty string/i);
// 2. ObjectSchema enforces dependent property requirements specified by the requires array
assert.throws(() => {
schema.validate({
name: "test-object",
secret: "secret-key"
});
}, /requires/i);
// 3. ObjectSchema supports custom validation and merge functions and ignores key updates when merge strategy returns undefined
assert.throws(() => {
schema.validate({
id: 1,
name: "test-object",
custom: "invalid_value"
});
}, /custom must start with valid_/);
const mergeSchema = new ObjectSchema({
key: {
required: false,
merge(first, second) {
if (second === "ignore") {
return undefined;
}
return second;
},
validate: "string"
}
});
const m1 = mergeSchema.merge({ key: "val" }, { key: "ignore" });
assert.equal(m1.key, "val");
// 4. ObjectSchema merges multiple objects using built-in merge strategies assign, overwrite, and replace
const obj1 = {
id: 10,
name: "initial",
flags: { x: 1 },
custom: "valid_a",
nested: { subKey: "initial-sub" }
};
const obj2 = {
id: 20,
name: "updated",
flags: { y: 2 },
custom: "valid_b",
tag: "tag2",
nested: { subKey: "updated-sub" }
};
const merged = schema.merge(obj1, obj2);
assert.equal(merged.id, 20);
assert.equal(merged.name, "updated");
assert.deepEqual(merged.flags, { x: 1, y: 2 });
assert.equal(merged.custom, "valid_a:valid_b");
assert.equal(merged.tag, "tag2");
assert.deepEqual(merged.nested, { subKey: "updated-sub" });
// 5. ValidationStrategy and MergeStrategy static methods correctly validate primitive and complex types and execute merge algorithms
assert.doesNotThrow(() => ValidationStrategy.array([]));
assert.doesNotThrow(() => ValidationStrategy.boolean(true));
assert.doesNotThrow(() => ValidationStrategy.number(42));
assert.doesNotThrow(() => ValidationStrategy.object({}));
assert.doesNotThrow(() => ValidationStrategy["object?"](null));
assert.doesNotThrow(() => ValidationStrategy["object?"]({}));
assert.doesNotThrow(() => ValidationStrategy.string("hello"));
assert.doesNotThrow(() => ValidationStrategy["string!"]("hello"));
assert.throws(() => ValidationStrategy.array("not-array"), TypeError);
assert.throws(() => ValidationStrategy.boolean(0), TypeError);
assert.throws(() => ValidationStrategy.number("42"), TypeError);
assert.throws(() => ValidationStrategy.object(null), TypeError);
assert.throws(() => ValidationStrategy.string(123), TypeError);
assert.throws(() => ValidationStrategy["string!"](""), TypeError);
assert.equal(MergeStrategy.overwrite("a", "b"), "b");
assert.equal(MergeStrategy.replace("a", undefined), "a");
assert.equal(MergeStrategy.replace("a", "b"), "b");
assert.deepEqual(MergeStrategy.assign({ a: 1 }, { b: 2 }), { a: 1, b: 2 });
console.log("Contract verified successfully.");
오리진 시더
익명