Sample
@eslint/object-schema 2.1.7: ObjectSchema
Verified sample for npm @eslint/object-schema 2.1.7: ObjectSchema. The contract ran on node 22 · linux debian/x64 · docker and passed.
sha256:bb92cd7773098d62df401c9a6730ea568d847c4d365f798f193a591eda9ce2bd
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-06 |
Case
HOW- Goal
- verify @eslint/object-schema.ObjectSchema in pkg:npm/%40eslint/object-schema@2.1.7
- Packages
- Symbols
-
- @eslint/object-schema.ObjectSchema
- Created
- 2026-09-06T10:28:52Z
Contract
- ObjectSchema instantiates with key definitions and checks key presence using hasKey
- ObjectSchema validates objects against definitions and rejects unexpected keys, missing required keys, or invalid value types
- ObjectSchema enforces dependency constraints between keys using requires
- ObjectSchema supports custom validation functions and custom merge functions that retain existing values when returning undefined
- ObjectSchema recursively validates nested objects defined by subschemas
- ObjectSchema merges multiple objects using assign, overwrite, and replace strategies
- ValidationStrategy and MergeStrategy provide static helper methods for type validation and merge logic
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 @eslint/object-schema.ObjectSchema in 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:
- @eslint/object-schema.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:82cf096b71e8a1a74e2da426ebd4a2c1e6c5b96ccfda3828ad8b676223d356e4","contract":["ObjectSchema instantiates with key definitions and checks key presence using hasKey","ObjectSchema validates objects against definitions and rejects unexpected keys, missing required keys, or invalid value types","ObjectSchema enforces dependency constraints between keys using requires","ObjectSchema supports custom validation functions and custom merge functions that retain existing values when returning undefined","ObjectSchema recursively validates nested objects defined by subschemas","ObjectSchema merges multiple objects using assign, overwrite, and replace strategies","ValidationStrategy and MergeStrategy provide static helper methods for type validation and merge logic"],"goal":"verify @eslint/object-schema.ObjectSchema in pkg:npm/%40eslint/object-schema@2.1.7","kind":"HOW","packages":["pkg:npm/%40eslint/object-schema@2.1.7"],"schemaVersion":1,"symbols":["@eslint/object-schema.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":["@eslint/object-schema.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",
"type": "module",
"private": true,
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"@eslint/object-schema": "2.1.7"
}
}
{
"schemaVersion": 1,
"goal": "verify @eslint/object-schema.ObjectSchema in pkg:npm/%40eslint/object-schema@2.1.7",
"kind": "HOW",
"packages": [
"pkg:npm/%40eslint/object-schema@2.1.7"
],
"symbols": [
"@eslint/object-schema.ObjectSchema"
]
}
import assert from "node:assert/strict";
import { ObjectSchema, ValidationStrategy, MergeStrategy, createConfigSchema } from "../index.mjs";
// 1. ObjectSchema instantiates with key definitions and checks key presence using hasKey
const schema = createConfigSchema({
id: {
required: true,
merge: "replace",
validate: "number"
},
name: {
required: true,
merge: "overwrite",
validate: "string!"
},
tag: {
required: false,
merge: "overwrite",
validate: "string"
},
settings: {
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"
},
token: {
required: false,
requires: ["id"],
merge: "replace",
validate: "string"
},
customField: {
required: false,
merge(first, second) {
if (second === "retain") return undefined;
return [first, second].filter(Boolean).join(":");
},
validate(val) {
if (typeof val !== "string" || (!val.startsWith("val_") && val !== "retain")) {
throw new TypeError("Must start with val_ or be retain");
}
}
},
nestedConfig: {
required: false,
merge: "assign",
validate: "object",
schema: {
subKey: {
required: false,
merge: "replace",
validate: "string"
}
}
}
});
assert.equal(schema.hasKey("id"), true);
assert.equal(schema.hasKey("name"), true);
assert.equal(schema.hasKey("nonexistent"), false);
// 2. ObjectSchema validates objects against definitions and rejects unexpected keys, missing required keys, or invalid value types
assert.doesNotThrow(() => {
schema.validate({
id: 1,
name: "main-item",
tag: "alpha",
settings: { enabled: true },
items: [1, 2, 3],
metadata: null,
enabled: true,
token: "tok_123",
customField: "val_one",
nestedConfig: { subKey: "inner" }
});
});
assert.throws(() => {
schema.validate({
id: 1
});
}, /Missing required key/i);
assert.throws(() => {
schema.validate({
id: 1,
name: "main-item",
unexpected: true
});
}, /Unexpected key/i);
assert.throws(() => {
schema.validate({
id: "not-a-number",
name: "main-item"
});
}, /Expected a number/i);
assert.throws(() => {
schema.validate({
id: 1,
name: ""
});
}, /Expected a non-empty string/i);
// 3. ObjectSchema enforces dependency constraints between keys using requires
assert.throws(() => {
schema.validate({
name: "main-item",
token: "tok_123"
});
}, /requires keys/i);
// 4. ObjectSchema supports custom validation functions and custom merge functions that retain existing values when returning undefined
assert.throws(() => {
schema.validate({
id: 1,
name: "main-item",
customField: "bad_val"
});
}, /Must start with val_/);
const initialObj = { id: 1, name: "item1", customField: "val_a" };
const retainObj = { id: 2, name: "item2", customField: "retain" };
const mergeRetained = schema.merge(initialObj, retainObj);
assert.equal(mergeRetained.customField, "val_a");
// 5. ObjectSchema recursively validates nested objects defined by subschemas
assert.throws(() => {
schema.validate({
id: 1,
name: "main-item",
nestedConfig: { subKey: 999 }
});
}, /Expected a string/i);
// 6. ObjectSchema merges multiple objects using assign, overwrite, and replace strategies
const objA = {
id: 100,
name: "initial-name",
tag: "v1",
settings: { timeout: 5000 },
customField: "val_first",
nestedConfig: { subKey: "v1-inner" }
};
const objB = {
id: 200,
name: "updated-name",
settings: { retries: 3 },
items: ["elem1"],
customField: "val_second",
nestedConfig: { subKey: "v2-inner" }
};
const merged = schema.merge(objA, objB);
assert.equal(merged.id, 200);
assert.equal(merged.name, "updated-name");
assert.equal(merged.tag, "v1");
assert.deepEqual(merged.settings, { timeout: 5000, retries: 3 });
assert.deepEqual(merged.items, ["elem1"]);
assert.equal(merged.customField, "val_first:val_second");
assert.deepEqual(merged.nestedConfig, { subKey: "v2-inner" });
// 7. ValidationStrategy and MergeStrategy provide static helper methods for type validation and merge logic
assert.doesNotThrow(() => ValidationStrategy.array([]));
assert.doesNotThrow(() => ValidationStrategy.boolean(true));
assert.doesNotThrow(() => ValidationStrategy.number(3.14));
assert.doesNotThrow(() => ValidationStrategy.object({ key: "val" }));
assert.doesNotThrow(() => ValidationStrategy["object?"](null));
assert.doesNotThrow(() => ValidationStrategy["object?"]({}));
assert.doesNotThrow(() => ValidationStrategy.string("hello"));
assert.doesNotThrow(() => ValidationStrategy["string!"]("non-empty"));
assert.throws(() => ValidationStrategy.array("string"), TypeError);
assert.throws(() => ValidationStrategy.boolean(0), TypeError);
assert.throws(() => ValidationStrategy.number("42"), TypeError);
assert.throws(() => ValidationStrategy.object(null), TypeError);
assert.throws(() => ValidationStrategy.string(100), 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.");
Origin Seeder
anonymous