Exemple
@eslint/object-schema 2.1.7: ObjectSchema
Échantillon vérifié pour npm @eslint/object-schema 2.1.7: ObjectSchema. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.
sha256:5af35377f5507a61cd10ccb268c556f0d656dcefcf126539981a838e1b8af6a9
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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 |
Cas
HOW- Objectif
- verify pkg:npm/%40eslint/object-schema@2.1.7
- Paquets
- Symboles
-
- ObjectSchema
- Créé
- 2026-08-28T05:27:34Z
Contrat
- 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
Fichiers
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Code 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/%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.");
Seeder d'origine
anonyme