{"name":"@cfworker/json-schema","version":"4.1.3","keywords":["json-schema","jsonschema","json","schema","cloudflare","worker","workers","service-worker"],"author":{"name":"Jeremy Danyow","email":"jdanyow@gmail.com"},"license":"MIT","_id":"@cfworker/json-schema@4.1.3","maintainers":[{"name":"jdanyow","email":"jdanyow@gmail.com"}],"homepage":"https://github.com/cfworker/cfworker/tree/master/packages/json-schema/README.md","bugs":{"url":"https://github.com/cfworker/cfworker/issues"},"dist":{"shasum":"bc6d12e6be1db37ee73749ad667092ec1201ab2c","tarball":"http://registry-npm.ywwl.com/@cfworker/json-schema/download/@cfworker/json-schema-4.1.3.tgz","fileCount":94,"integrity":"sha512-7WJxlFqM6opWUGEt3uzf0YePLow50lWtVAA4iyLS/eOXu1hrVohpa/1/4nx/PyeqH4Yb0UmYoJyt6cWdRBABhQ==","signatures":[{"sig":"MEUCIQCI1ozfLhiJ0S1knUbCC5sdzNelCTXcDrpXh6SjhB3dgQIgczkVozlXINN5Z0c3lYe+ljheUvvUDajh9Owxh9MlzxA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIQDDGIMZ/SyiC5OarQ6Om5FMeCEDNRWUULfwa7S9tcjiAwIgNxWalhS3Ip+gWy/cj8SQktjCfPa38rcx8Tr8nPNSaDY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@cfworker%2fjson-schema@4.1.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":390976,"size":59354,"noattachment":false,"key":"/@cfworker/json-schema/-/@cfworker/json-schema-4.1.3.tgz"},"main":"./dist/commonjs/index.js","tshy":{"exports":{".":"./src/index.ts","./package.json":"./package.json"},"project":"./tsconfig.build.json"},"type":"module","types":"./dist/commonjs/index.d.ts","module":"./dist/esm/index.js","exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"gitHead":"d2950943c8e331f861df1cfa527ac2161c3fc330","scripts":{"test":"node ../../test.mjs","build":"tshy","clean":"tsc --build tsconfig.build.json --clean","prepare":"tshy","pretest":"node --experimental-import-meta-resolve suite-gen.mjs && esbuild test/test.ts --target=esnext --bundle --format=esm --conditions=worker,browser --outdir=dist-test --ignore-annotations","typecheck":"tsc --project tsconfig.json","pretypecheck":"node --experimental-import-meta-resolve suite-gen.mjs"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"5d552c2a-4317-4f22-ac96-4e6b47527a14"}},"repository":{"url":"git+https://github.com/cfworker/cfworker.git","type":"git"},"_npmVersion":"11.20.0","description":"A JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, 2019-09, and 2020-12.","directories":{},"sideEffects":false,"_nodeVersion":"26.13.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^6.3.0","mocha":"^12.0.3","esbuild":"^0.28.2","wrangler":"^4.156.0","typescript":"^7.0.2","@types/chai":"^5.2.3","@types/mocha":"^10.0.10","json-schema-test-suite":"git+https://github.com/json-schema-org/JSON-Schema-Test-Suite.git#89e83a7"},"_npmOperationalInternal":{"tmp":"tmp/json-schema_4.1.3_1793339982764_0.18397414519482702","host":"s3://npm-registry-packages-npm-production"},"readme":"# @cfworker/json-schema\n\n![](https://badgen.net/bundlephobia/minzip/@cfworker/json-schema)\n![](https://badgen.net/bundlephobia/min/@cfworker/json-schema)\n![](https://badgen.net/bundlephobia/dependency-count/@cfworker/json-schema)\n![](https://badgen.net/bundlephobia/tree-shaking/@cfworker/json-schema)\n![](https://badgen.net/npm/types/@cfworker/json-schema?icon=typescript)\n\nA JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, 2019-09, and 2020-12.\n\nThis library is validated against the [json-schema-test-suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite), a series of approximately 4,500 assertions maintained along with the json-schema specification. A small set of test cases are intentionally not supported due to performance constraints or lack of feature use. These list of unsupported features are maintained in [test/unsupported.ts](./test/unsupported.ts). While this library is not the fastest due to lack of code generation, it's consistently among the [most spec compliant](https://json-schema.org/implementations.html#benchmarks).\n\n## Background\n\n_Why another JSON schema validator?_\n\nCloudflare workers do not have APIs required by [Ajv](https://ajv.js.org/) schema compilation (`eval` or `new Function(code)`).\nIf possible use Ajv in a build step to precompile your schema. Otherwise this library could work for you.\n\n## Basic usage\n\n```js\nimport { Validator } from '@cfworker/json-schema';\n\nconst validator = new Validator({ type: 'number' });\n\nconst result = validator.validate(7);\n```\n\n## Specify meta schema draft\n\n```js\nconst validator = new Validator({ type: 'number' }, '4'); // draft-4\n```\n\n## Add schemas\n\n```js\nconst validator = new Validator({\n  $id: 'https://foo.bar/baz',\n  $ref: '/beep'\n});\n\nvalidator.addSchema({ $id: 'https://foo.bar/beep', type: 'boolean' });\n```\n\n## Include all errors\n\nBy default the validator stops processing after the first error. Set the `shortCircuit` parameter to `false` to emit all errors.\n\n```js\nconst shortCircuit = false;\n\nconst draft = '2019-09';\n\nconst schema = {\n  type: 'object',\n  required: ['name', 'email', 'number', 'bool'],\n  properties: {\n    name: { type: 'string' },\n    email: { type: 'string', format: 'email' },\n    number: { type: 'number' },\n    bool: { type: 'boolean' }\n  }\n};\n\nconst validator = new Validator(schema, draft, shortCircuit);\n\nconst result = validator.validate({\n  name: 'hello',\n  email: 5, // invalid type\n  number: 'Hello' // invalid type\n  bool: 'false' // invalid type\n});\n```\n","publish_time":1793339982895,"_cnpm_publish_time":1793339982895,"dist-tags":{"latest":"4.1.6"}}