샘플
@sinclair/typebox 0.27.12: Value
검증된 샘플 — npm @sinclair/typebox 0.27.12: Value. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: Value.Check verifies conforming values against…
sha256:7e35b504c68c2b4679ad4da11b015c2d1d3b7b059244b7abf0edbb56d3c31b3f
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-03 |
케이스
HOW- 목표
- verify @sinclair/typebox.Value in pkg:npm/%40sinclair/typebox@0.27.12
- 심벌
-
- @sinclair/typebox.Value
- 생성일
- 2026-09-03T07:28:30Z
컨트랙트
- Value.Check verifies conforming values against schema definitions and rejects mismatches
- Value.Cast populates missing default properties and coerces types to satisfy schema
- Value.Create generates minimum valid instances matching schema definitions
- Value.Convert coerces string representations of primitives into expected schema types
- Value.Clone creates independent deep structural copies of objects and arrays
- Value.Equal evaluates deep structural equality across objects and collections
- Value.Diff and Value.Patch compute and apply structural delta changesets between objects
- Value.Mutate updates target object properties in-place to mirror source values
- Value.Errors returns detailed error objects with schema paths and messages for invalid data
- Value.Hash produces consistent 64-bit BigInt hash invariant to object key ordering
파일
- 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 @sinclair/typebox.Value in pkg:npm/%40sinclair/typebox@0.27.12
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40sinclair/typebox@0.27.12
Demonstrate these symbols/APIs:
- @sinclair/typebox.Value
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:f9fd5c923cdccc078b94e153818bb7e1494fe8b385a63d52348e72caaaa96566","contract":["Value.Check verifies conforming values against schema definitions and rejects mismatches","Value.Cast populates missing default properties and coerces types to satisfy schema","Value.Create generates minimum valid instances matching schema definitions","Value.Convert coerces string representations of primitives into expected schema types","Value.Clone creates independent deep structural copies of objects and arrays","Value.Equal evaluates deep structural equality across objects and collections","Value.Diff and Value.Patch compute and apply structural delta changesets between objects","Value.Mutate updates target object properties in-place to mirror source values","Value.Errors returns detailed error objects with schema paths and messages for invalid data","Value.Hash produces consistent 64-bit BigInt hash invariant to object key ordering"],"goal":"verify @sinclair/typebox.Value in pkg:npm/%40sinclair/typebox@0.27.12","kind":"HOW","packages":["pkg:npm/%40sinclair/typebox@0.27.12"],"schemaVersion":1,"symbols":["@sinclair/typebox.Value"]},"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/%40sinclair/typebox@0.27.12"],"schemaVersion":1,"subject":"pkg:npm/%40sinclair/typebox@0.27.12","symbols":["@sinclair/typebox.Value"],"verifierAdapter":"node-typescript@1"}
import { Type } from '@sinclair/typebox';
import { Value } from '@sinclair/typebox/value';
export { Type, Value };
export function checkValue(schema, value) {
return Value.Check(schema, value);
}
export function castValue(schema, value) {
return Value.Cast(schema, value);
}
export function createValue(schema) {
return Value.Create(schema);
}
export function convertValue(schema, value) {
return Value.Convert(schema, value);
}
export function cloneValue(value) {
return Value.Clone(value);
}
export function equalValues(a, b) {
return Value.Equal(a, b);
}
export function diffValues(current, next) {
return Value.Diff(current, next);
}
export function patchValue(current, diff) {
return Value.Patch(current, diff);
}
export function mutateValue(current, next) {
Value.Mutate(current, next);
return current;
}
export function getErrors(schema, value) {
return [...Value.Errors(schema, value)];
}
export function hashValue(value) {
return Value.Hash(value);
}
export default {
Type,
Value,
checkValue,
castValue,
createValue,
convertValue,
cloneValue,
equalValues,
diffValues,
patchValue,
mutateValue,
getErrors,
hashValue,
};
{
"name": "sample-typebox-value",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-typebox-value",
"version": "1.0.0",
"dependencies": {
"@sinclair/typebox": "0.27.12"
}
},
"node_modules/@sinclair/typebox": {
"version": "0.27.12",
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.12.tgz",
"integrity": "sha512-hhyNJ+nbR6ZR7pToHvllEFun9TL0sbL+tk/ON75lo+Xas054uez98qRbsuNt7MBCyZKK4+8Yli/OAGZhmfBZ/g==",
"license": "MIT"
}
}
}
{
"name": "sample-typebox-value",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"@sinclair/typebox": "0.27.12"
}
}
{
"schemaVersion": 1,
"goal": "verify @sinclair/typebox.Value in pkg:npm/%40sinclair/typebox@0.27.12",
"kind": "HOW",
"packages": [
"pkg:npm/%40sinclair/typebox@0.27.12"
],
"symbols": [
"@sinclair/typebox.Value"
]
}
import assert from 'node:assert/strict';
import {
Type,
Value,
checkValue,
castValue,
createValue,
convertValue,
cloneValue,
equalValues,
diffValues,
patchValue,
mutateValue,
getErrors,
hashValue,
} from '../index.mjs';
// Contract 1: Value.Check verifies conforming values against schema definitions and rejects mismatches
{
const schema = Type.Object({
name: Type.String({ minLength: 1 }),
count: Type.Number({ minimum: 0 }),
});
assert.strictEqual(checkValue(schema, { name: 'sample', count: 5 }), true);
assert.strictEqual(Value.Check(schema, { name: 'sample', count: 5 }), true);
assert.strictEqual(checkValue(schema, { name: '', count: 5 }), false);
assert.strictEqual(checkValue(schema, { name: 'sample', count: -1 }), false);
assert.strictEqual(checkValue(schema, { name: 'sample' }), false);
assert.strictEqual(checkValue(schema, null), false);
}
// Contract 2: Value.Cast populates missing default properties and coerces types to satisfy schema
{
const schema = Type.Object({
id: Type.Number(),
active: Type.Boolean({ default: true }),
tags: Type.Array(Type.String(), { default: [] }),
});
const partial = { id: 42 };
const casted = castValue(schema, partial);
assert.strictEqual(casted.id, 42);
assert.strictEqual(casted.active, true);
assert.deepStrictEqual(casted.tags, []);
assert.strictEqual(Value.Check(schema, casted), true);
}
// Contract 3: Value.Create generates minimum valid instances matching schema definitions
{
const schema = Type.Object({
id: Type.Number(),
name: Type.String(),
enabled: Type.Boolean({ default: false }),
items: Type.Array(Type.String()),
});
const created = createValue(schema);
assert.strictEqual(typeof created, 'object');
assert.notStrictEqual(created, null);
assert.strictEqual(typeof created.id, 'number');
assert.strictEqual(typeof created.name, 'string');
assert.strictEqual(created.enabled, false);
assert.deepStrictEqual(created.items, []);
assert.strictEqual(Value.Check(schema, created), true);
}
// Contract 4: Value.Convert coerces string representations of primitives into expected schema types
{
const schema = Type.Object({
port: Type.Number(),
secure: Type.Boolean(),
});
const raw = { port: '8080', secure: 'true' };
const converted = convertValue(schema, raw);
assert.strictEqual(typeof converted.port, 'number');
assert.strictEqual(converted.port, 8080);
assert.strictEqual(typeof converted.secure, 'boolean');
assert.strictEqual(converted.secure, true);
assert.strictEqual(Value.Check(schema, converted), true);
}
// Contract 5: Value.Clone creates independent deep structural copies of objects and arrays
{
const original = { id: 1, tags: ['alpha', 'beta'], meta: { nested: 100 } };
const cloned = cloneValue(original);
assert.deepStrictEqual(cloned, original);
assert.notStrictEqual(cloned, original);
assert.notStrictEqual(cloned.tags, original.tags);
assert.notStrictEqual(cloned.meta, original.meta);
cloned.tags.push('gamma');
cloned.meta.nested = 200;
assert.strictEqual(original.tags.length, 2);
assert.strictEqual(original.meta.nested, 100);
}
// Contract 6: Value.Equal evaluates deep structural equality across objects and collections
{
const a = { x: 1, list: [1, 2, 3] };
const b = { x: 1, list: [1, 2, 3] };
const c = { x: 1, list: [1, 2, 4] };
assert.strictEqual(equalValues(a, b), true);
assert.strictEqual(equalValues(a, c), false);
assert.strictEqual(Value.Equal(a, b), true);
assert.strictEqual(Value.Equal(a, c), false);
}
// Contract 7: Value.Diff and Value.Patch compute and apply structural delta changesets between objects
{
const current = { id: 1, status: 'pending', count: 10 };
const next = { id: 1, status: 'completed', count: 15, label: 'new' };
const diff = diffValues(current, next);
assert.ok(Array.isArray(diff));
assert.ok(diff.length > 0);
const patched = patchValue(current, diff);
assert.deepStrictEqual(patched, next);
}
// Contract 8: Value.Mutate updates target object properties in-place to mirror source values
{
const target = { id: 10, title: 'before', active: false };
const source = { id: 10, title: 'after', active: true };
const res = mutateValue(target, source);
assert.strictEqual(res, target);
assert.strictEqual(target.title, 'after');
assert.strictEqual(target.active, true);
}
// Contract 9: Value.Errors returns detailed error objects with schema paths and messages for invalid data
{
const schema = Type.Object({
email: Type.String({ minLength: 3 }),
age: Type.Number({ minimum: 18 }),
});
const invalid = { email: 'ab', age: 10 };
const errors = getErrors(schema, invalid);
assert.ok(Array.isArray(errors));
assert.strictEqual(errors.length, 2);
assert.ok(errors.some((e) => e.path === '/email'));
assert.ok(errors.some((e) => e.path === '/age'));
}
// Contract 10: Value.Hash produces consistent 64-bit BigInt hash invariant to object key ordering
{
const obj1 = { alpha: 'one', beta: 2, gamma: true };
const obj2 = { gamma: true, beta: 2, alpha: 'one' };
const hash1 = hashValue(obj1);
const hash2 = hashValue(obj2);
assert.strictEqual(typeof hash1, 'bigint');
assert.strictEqual(typeof hash2, 'bigint');
assert.strictEqual(hash1, hash2);
}
console.log('All Value contracts verified.');
오리진 시더
익명