サンプル
@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…
sha256:5af35377f5507a61cd10ccb268c556f0d656dcefcf126539981a838e1b8af6a9
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
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.");
オリジンシーダー
匿名