Exemplo
ajv 6.15.0
Amostra verificada para npm ajv 6.15.0. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: Ajv compiles JSON Schema definitions and validates…
sha256:69b0af6ac4ee7342630de8af41c093f1e1c5d4f46fdb1f3b1db975bb6857a8ad
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 npm
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify pkg:npm/ajv@6.15.0
- Pacotes
- Criado
- 2026-08-23T06:53:59Z
Contrato
- Ajv compiles JSON Schema definitions and validates data against type, range, and format constraints
- Ajv populates errors with keyword, dataPath, and params when validation fails
- Ajv resolves internal and cross-schema references via $id and $ref registered with addSchema
- Ajv with allErrors true collects all schema validation failures instead of stopping on first error
- Ajv with useDefaults true assigns default property values defined in the schema to target objects
- Ajv with coerceTypes true coerces data types to match expected schema property types
- Ajv supports custom keyword definitions with user-defined validation logic
Arquivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Código-fonte
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/ajv@6.15.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/ajv@6.15.0
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:39b091de6ffb5da6460a6fc7de83210f76700a1d64efbb2c20f0e5b0d0779f97","contract":["Ajv compiles JSON Schema definitions and validates data against type, range, and format constraints","Ajv populates errors with keyword, dataPath, and params when validation fails","Ajv resolves internal and cross-schema references via $id and $ref registered with addSchema","Ajv with allErrors true collects all schema validation failures instead of stopping on first error","Ajv with useDefaults true assigns default property values defined in the schema to target objects","Ajv with coerceTypes true coerces data types to match expected schema property types","Ajv supports custom keyword definitions with user-defined validation logic"],"goal":"verify pkg:npm/ajv@6.15.0","kind":"HOW","packages":["pkg:npm/ajv@6.15.0"],"schemaVersion":1},"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/ajv@6.15.0"],"schemaVersion":1,"subject":"pkg:npm/ajv@6.15.0","verifierAdapter":"node-typescript@1"}
{
"name": "sample-ajv",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-ajv",
"version": "1.0.0",
"dependencies": {
"ajv": "6.15.0"
}
},
"node_modules/ajv": {
"version": "6.15.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz",
"integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==",
"license": "MIT",
"dependencies": {
"fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.4.1",
"uri-js": "^4.2.2"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"license": "MIT"
},
"node_modules/fast-json-stable-stringify": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
"integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==",
"license": "MIT"
},
"node_modules/json-schema-traverse": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
"license": "MIT"
},
"node_modules/punycode": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/uri-js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
"integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
"license": "BSD-2-Clause",
"dependencies": {
"punycode": "^2.1.0"
}
}
}
}
{
"name": "sample-ajv",
"version": "1.0.0",
"private": true,
"type": "module",
"dependencies": {
"ajv": "6.15.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/ajv@6.15.0",
"kind": "HOW",
"packages": [
"pkg:npm/ajv@6.15.0"
]
}
import Ajv from 'ajv';
import assert from 'node:assert/strict';
// 1. Ajv compiles JSON Schema definitions and validates data against type, range, and format constraints
{
const ajv = new Ajv();
const schema = {
type: 'object',
properties: {
name: { type: 'string', minLength: 2 },
age: { type: 'integer', minimum: 0, maximum: 120 },
tags: {
type: 'array',
items: { type: 'string' },
uniqueItems: true
}
},
required: ['name', 'age']
};
const validate = ajv.compile(schema);
assert.strictEqual(validate({ name: 'Alice', age: 30, tags: ['dev', 'admin'] }), true);
assert.strictEqual(validate({ name: 'A', age: -1 }), false);
}
// 2. Ajv populates errors with keyword, dataPath, and params when validation fails
{
const ajv = new Ajv();
const schema = {
type: 'object',
properties: {
name: { type: 'string', minLength: 2 }
},
required: ['name']
};
const validate = ajv.compile(schema);
const isValid = validate({ name: 'A' });
assert.strictEqual(isValid, false);
assert(Array.isArray(validate.errors));
assert(validate.errors.length >= 1);
assert.strictEqual(validate.errors[0].keyword, 'minLength');
assert.strictEqual(validate.errors[0].dataPath, '.name');
assert.strictEqual(validate.errors[0].params.limit, 2);
}
// 3. Ajv resolves internal and cross-schema references via $id and $ref registered with addSchema
{
const ajv = new Ajv();
ajv.addSchema({
$id: 'http://example.com/schemas/address.json',
type: 'object',
properties: {
city: { type: 'string' },
zip: { type: 'string' }
},
required: ['city']
});
const userSchema = {
type: 'object',
properties: {
user: { type: 'string' },
address: { $ref: 'http://example.com/schemas/address.json' }
},
required: ['user', 'address']
};
const validateUser = ajv.compile(userSchema);
assert.strictEqual(validateUser({ user: 'Bob', address: { city: 'Seoul' } }), true);
assert.strictEqual(validateUser({ user: 'Bob', address: { zip: '12345' } }), false);
}
// 4. Ajv with allErrors true collects all schema validation failures instead of stopping on first error
{
const ajv = new Ajv({ allErrors: true });
const schema = {
type: 'object',
properties: {
a: { type: 'string' },
b: { type: 'number' }
},
required: ['a', 'b']
};
const validate = ajv.compile(schema);
const isValid = validate({ a: 123, b: 'not-a-number' });
assert.strictEqual(isValid, false);
assert.strictEqual(validate.errors.length, 2);
}
// 5. Ajv with useDefaults true assigns default property values defined in the schema to target objects
{
const ajv = new Ajv({ useDefaults: true });
const schema = {
type: 'object',
properties: {
role: { type: 'string', default: 'guest' },
active: { type: 'boolean', default: true }
}
};
const validate = ajv.compile(schema);
const data = {};
const isValid = validate(data);
assert.strictEqual(isValid, true);
assert.strictEqual(data.role, 'guest');
assert.strictEqual(data.active, true);
}
// 6. Ajv with coerceTypes true coerces data types to match expected schema property types
{
const ajv = new Ajv({ coerceTypes: true });
const schema = {
type: 'object',
properties: {
count: { type: 'number' },
enabled: { type: 'boolean' }
}
};
const validate = ajv.compile(schema);
const data = { count: '42', enabled: 'true' };
const isValid = validate(data);
assert.strictEqual(isValid, true);
assert.strictEqual(data.count, 42);
assert.strictEqual(data.enabled, true);
}
// 7. Ajv supports custom keyword definitions with user-defined validation logic
{
const ajv = new Ajv();
ajv.addKeyword('range', {
type: 'number',
compile: function (sch) {
const [min, max] = sch;
return function (val) {
return val >= min && val <= max;
};
}
});
const schema = {
type: 'object',
properties: {
score: { range: [10, 50] }
}
};
const validate = ajv.compile(schema);
assert.strictEqual(validate({ score: 25 }), true);
assert.strictEqual(validate({ score: 5 }), false);
assert.strictEqual(validate({ score: 55 }), false);
}
Seeder de origem
anônimo