{"name":"@cfworker/json-schema","version":"1.11.0","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@1.11.0","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":"37f8c7dc490b86847adf204c303443e9313a5238","tarball":"http://registry-npm.ywwl.com/@cfworker/json-schema/download/@cfworker/json-schema-1.11.0.tgz","fileCount":30,"integrity":"sha512-Z4pv4geilCtXjXusVkS9AVccnRue0L9zNm9xJYeq0KhPAruZBo+XwUHak6OZFFki+CHEy8bI3GjqVu1kdm56Og==","signatures":[{"sig":"MEYCIQDy+guPZmggeZe/P7vymvMFOdplaFeIuZ9cP0V91VzyYwIhANdIPBQU/IEnh0TobF9h2du/XMN+WVsrb5nNTkKUgz5z","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":112924,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhoVwwCRA9TVsSAnZWagAA+80QAIeaAV1QbZyur4OtYePW\npFJ74NRzncoX7jWm/Ab5xLUlAJy1bL8linTLVvgGMZ+3xDH1GH1TzWYMon9D\n3W8L5eRVjZVE7emkAu2Sndtx4Xr4w8A8xU0EQ4rc2jadRJ6nGJHsHEfucBnb\nn2kHsetG/mDlYXuwn6mYJGTFfJ6JlW+iNuLKq6OO90DSu4gIZWcvk7bHuEJ+\njKzhRvZU+/llDyCwvyuEY5Jb0LNczqIrkMTTunJlTPqJ3/4Mn+wCh//zjLna\nTmjW9cytw4WN+yR+RTyjr2tBBuAx1BN1QrkyVsmBEbrbDwXP0IfR9mxI+c++\nMs056wCUa/GXisdNKxwmc3O2reXSIuqMu/xv70ij6yK75QrBsld4KdvgpYzw\nYOvTtyS8VaCAlDFqvl4WSCbbbiWKkibrzpYnU5yUh6ISvzw95eZqwSF6WPJB\nrb+sCZv8lRICe3k00GPQA8utuS9dMBuMW1YMDQaVM7hm9xWyETFIDz0vToy0\nHkyX5cvKZ7DgfvA3l5EwMJY5FJcesOz2WAnAVWzOoVmNCf/hofPT8nynsvFC\n2A+N4ov4XeonX4ngKsW9kpJrA1C4qZ9bKnJnpmKe1iTLdbkjGxUfdBje69D4\nTg3yuJFvNygAwnvBp87Xe5E2ssLv/Vxvon9wA8alBPlNyfhr18B60zlJnU+v\npw9k\r\n=lWTO\r\n-----END PGP SIGNATURE-----\r\n","size":20691,"noattachment":false,"key":"/@cfworker/json-schema/-/@cfworker/json-schema-1.11.0.tgz"},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","source":"src/index.ts","scripts":{"test":"cfworker test test/**/*.spec.ts --nocheck","build":"tsc --build","clean":"tsc --build --clean","pretest":"node --experimental-import-meta-resolve suite-gen.js"},"_npmUser":{"name":"jdanyow","email":"jdanyow@gmail.com"},"repository":{"url":"git+https://github.com/cfworker/cfworker.git","type":"git"},"_npmVersion":"7.18.1","description":"A JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, 2019-09, and 2020-12.","directories":{},"sideEffects":false,"_nodeVersion":"16.4.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.3.4","mocha":"^9.1.3","typescript":"^4.5.2","@types/chai":"^4.2.22","@types/mocha":"^9.0.0","@cfworker/dev":"^1.11.0","json-schema-test-suite":"git+https://github.com/json-schema-org/JSON-Schema-Test-Suite.git#76b529f"},"_npmOperationalInternal":{"tmp":"tmp/json-schema_1.11.0_1637964848207_0.9710998758695597","host":"s3://npm-registry-packages"},"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":1637964848544,"_cnpm_publish_time":1637964848544,"dist-tags":{"latest":"4.1.6"}}